N = 2**int(input()) terms = [] for i in range(N): *Q, R = map(int, input().split()) p = [] if R: for j, q in enumerate(Q): p.append('{}P_{}'.format('' if q else '¬', j+1)) terms.append('(' + '∧'.join(p) + ')') if len(terms) == N: print('A=⊤') elif len(terms) == 0: print('A=⊥') else: print('A=' + '∨'.join(terms))