N = int(input()) count = 0 result = [] for _ in range(2 ** N): *Q, R = [int(i) for i in input().split()] if R == 1: count += 1 temp = [] for i, qi in enumerate(Q): if qi == 1: temp.append("P_" + str(i + 1)) else: temp.append("¬P_" + str(i + 1)) s = "({})".format("∧".join(temp)) result.append(s) if count == 0: ans = "⊥" elif count == 2 ** N: ans = "⊤" else: ans = "∨".join(result) print("A={}".format(ans))