n = int(input()) flg = False ans = "" for _ in range(2 ** n): tmp = [int(x) for x in input().split()] q = tmp[:-1] r = tmp[-1] if r == 1: if ans != "": ans += "∨" ans += "(" for j, v in enumerate(q): if j != 0: ans += "∧" if v == 0: ans += "¬" ans += "P_" + str(j + 1) ans += ")" else: flg = True if ans == "": ans = "⊥" elif not flg: ans = "⊤" print("A=", ans, sep="")