a = []
n = gets.to_i
(2**n).times.map{
  b = gets.split.map &:to_i
  if b[-1] == 1
    a << b[0..-2]
  end
}
if a.length==0
  puts "A=⊥"
elsif a.length==(2**n)
  puts "A=⊤"
else
  puts "A=#{a.map{|b| "(" + b.map.with_index{|c, i| ["¬",""][c]+"P_"+(i+1).to_s}*'∧' + ")"}*'v'}"
end