#include #define rep(i,a,b) for(int i=a;i>n; vector buf; int q[n],r; rep(_, 0, 1 << n) { rep(i, 0, n) cin >> q[i]; cin >> r; if (r == 1) { string expr = ""; rep(i, 0, n) { if (i) expr += "∧"; if (q[i] == 0) expr += "¬P_" + to_string(i + 1); else expr += "P_" + to_string(i + 1); } buf.push_back(expr); } } if (buf.size() == 0) cout << "A=⊥" << endl; else if (buf.size() == (1 << n)) cout << "A=⊤" << endl; else { int n = buf.size(); string ans = "A="; rep(i, 0, n) { if (i) ans += "∨"; ans += "(" + buf[i] + ")"; } cout << ans << endl; } }