gets;s=*?0..?9;$<.map{|i|a=i.split;i[11]?s&=a :s-=a};puts s