n = int(input()) q = [[int(i) for i in input().split()] for j in range(2**n)] ans = "A=" f = False f_all = True for i in range(2**n): if q[i][-1] == 1: if len(ans) != 2: ans = "".join([ans,"∨"]) f = True ans += ans.join("(") for j in range(n): if q[i][j] == 1: ans = "".join([ans,"P_"+str(j+1)]) else: ans = "".join([ans,"¬P_"+str(j+1)]) if j != n-1: ans = "".join([ans,"∧"]) ans = "".join([ans,")"]) else: f_all = False if f == False: ans = "A=⊥" elif f_all == True: ans = "A=⊤" print(ans)