# No.792 真理関数をつくろう n = int(input()) q = [] r = [] a = 'A=' for _ in range(2 ** n): s = input().split() q.append(s[:-1]) r.append(s[-1]) if r.count('0') == 0: print(a + '⊤') elif r.count('1') == 0: print(a + '⊥') else: a += '(' for i in range(2 ** n): if r[i] == '1': for j in range(n): if q[i][j] == '0': a += '¬P_' + str(j + 1) + '∧' else: a += 'P_' + str(j + 1) + '∧' a = a[:-1] + ')∨(' print(a[:-2])