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 ans != "A=": ans += "∨" f = True ans += ans.join("(") for j in range(n): if q[i][j] == 1: ans += ans.join("P_"+str(j+1)) else: ans += ans.join("¬P_"+str(j+1)) if j != n-1: ans += ans.join("∧") ans += ans.join(")") else: f_all = False if f == False: ans = "A=⊥" elif f_all == True: ans = "A=⊤" print(ans)