N = int(input()) cnt = 0 ans = [] for i in range(2**N): tmp = list(map(int, input().strip().split())) Q, R = tmp[:-1], tmp[-1] if R == 1: cnt += 1 ans.append('(' + '∧'.join([('P_' if j == 1 else '¬P_') + str(n+1) for n, j in enumerate(Q)]) + ')') if cnt == 0: ans = 'A=⊥' elif cnt == 2**N: ans = 'A=⊤' else: ans = 'A=' + '∨'.join(ans) print(ans)