d=1 (0...gets.to_i).map{v,t=gets.split.map &:to_i;[t,v]}.sort.each{|a|d|=d%(1<0?d.bit_length-1:0