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