n = read_line.to_i m = 2 ** n q = Array.new(m) { read_line.split.map &.to_i }.select { |a| a[n] == 1 } puts "A=" + if q.size == m "⊤" elsif q.size == 0 "⊥" else q.join("∨") { |a| "(" + a[0...n].each_with_index(1).join("∧") { |v, i| v == 1 ? "P_#{i}" : "¬P_#{i}" } + ")" } end