v, w, x, y, z = "∧", "∨", "¬", "⊥", "⊤" n = io.read("*n") all0, all1 = true, true tot = math.pow(2, n) t = {} for i = 1, tot do s = "(" for j = 1, n do if(1 < j) then s = string.format("%s%s", s, v) end a = io.read("*n") if(a == 0) then s = string.format("%s%sP_%d", s, x, j) else s = string.format("%sP_%d", s, j) end end a = io.read("*n") if(a == 1) then all0 = false s = string.format("%s)", s) table.insert(t, s) else all1 = false end end io.write("A=") if(all0) then io.write(y) elseif(all1) then io.write(z) else first = true for k, v in pairs(t) do if(first) then first = false else io.write(w) end io.write(v) end end io.write("\n")