def solve(): n = int(input()) QR = [input().split() for _ in range(n ** 2)] R = set(list(zip(*QR))[-1]) print("A=", end="") if R == {"0"}: print("⊥") return if R == {"1"}: print("⊤") return ans = [] for ss in QR: if ss[-1] == "1": ret = [] for i, s in enumerate(ss[:-1], 1): if s == '1': ret.append("P_" + str(i)) else: ret.append("¬P_" + str(i)) ans.append("(" + "∧".join(ret) + ")") print("∨".join(ans)) solve()