n=gets.to_i a=[] u=$<.map{|s| *q,r=s.split.map &:to_i if r==1 a<<"(#{n.times.map{|i|"#{q[i]==0?"¬":""}P_#{i+1}"}*"∧"})" end r }.uniq puts "A="+(u==[0]?"⊥":u==[1]?"⊤":a*"∨")