d={ "p":["r", "r"], "s":["k", "s"], "k":["k", "p"], "r":["p", "s"] } input() pb={"p", "s"} for v in input().split(" "): if v=="-1": t0={d[x][0] for x in pb} t1={d[x][1] for x in pb} pb=t0.union(t1) #Leidke tulemushulk 0 korral #Leidke tulemushulk 1 korral #ühendage tulemused pb-muutujasse else: pb={d[x][int(v)] for x in pb} print(pb)