N = int(input()) ans = "A=" cnt = 0 for i in range(2**N): l = list(map(int,input().split())) if l[-1] == 0: continue cnt += 1 if ans != "A=": ans += "∨" ans += "(" for j in range(N): s = "P_" + str(j + 1) if l[j] == 0: s = "¬" + s if j != 0: s = "∧" + s ans += s ans += ")" if ans == "A=": ans = "A=⊥" if cnt == 2**N: ans = "A=⊤" print(ans)