import java.io.*; import java.util.Scanner; public class Main_yukicoder792 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int n2 = 0x1 << n; boolean[][] q = new boolean[n2][n]; boolean[] r = new boolean[n2]; for (int i = 0; i < n2; i++) { for (int j = 0; j < n; j++) { q[i][j] = sc.next().equals("1"); } r[i] = sc.next().equals("1"); } StringBuilder sb = new StringBuilder(); int cnt = 0; for (int i = 0; i < n2; i++) { if (r[i]) { cnt++; if (sb.length() > 0) { sb.append("∨"); } StringBuilder qq = new StringBuilder(); qq.append('('); for (int j = 0; j < n; j++) { if (j > 0) { qq.append("∧"); } if (!q[i][j]) { qq.append("¬"); } qq.append("P_"); qq.append(j + 1); } qq.append(')'); sb.append(qq); } } if (cnt == 0) { pr.println("A=⊥"); } else if (cnt == n2) { pr.println("A=⊤"); } else { pr.printf("A=%s%n", sb.toString()); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }