s=*?0..?9 $<.map{|e|*a,b=e.split;b>?Y?s&=a:s-=a} puts s