import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); StringBuilder sb = new StringBuilder(); int trueCount = 0; int falseCount = 0; sb.append("A="); boolean isFirst = true; for (int i = 0; i < (1 << n); i++) { char[] line = sc.nextLine().toCharArray(); boolean[] tfs = new boolean[n + 1]; for (int j = 0; j < line.length; j += 2) { tfs[j / 2] = (line[j] == '1'); } if (tfs[n]) { trueCount++; if (!isFirst) { sb.append("∨"); } isFirst = false; sb.append("("); for (int j = 0; j < n; j++) { if (j > 0) { sb.append("∧"); } if (!tfs[j]) { sb.append("¬"); } sb.append("P_").append(j + 1); } sb.append(")"); } else { falseCount++; } } if (trueCount == (1 << n)) { System.out.println("A=⊤"); } else if (falseCount == (1 << n)) { System.out.println("A=⊥"); } else { System.out.println(sb); } } }