N = int(input()) lsR = [] lsQ = [] for i in range(2**N): ls = list(map(int,input().split())) Q = ls[:-1] R = ls[-1] lsQ.append(Q) lsR.append(R) ans = ['A='] if lsR.count(0)==0: print('A=⊤') elif lsR.count(1)==0: print('A=⊥') else: for i in range(2**N): l = [] l.append('(') if lsR[i] == 1: for j in range(N): if lsQ[j] == 1: l.append('P_{}'.format(j+1)) else: l.append('¬P_{}'.format(j+1)) l.append('∧') l.pop() l.append(')') ans.append(''.join(l)) ans.append('∨') ans.pop() print(''.join(ans))