















score = []
until (t = gets.split(',').map(&:to_i))== [0,0]
&#160; &#160; score << [t[0] , t[1], 0]
end
















score.sort!{ |x, y| x[1] <=> y[1] }.reverse!
score.length.times do |i|
# &#160; &#160;p score
&#160; &#160; if i == 0
&#160; &#160; &#160; &#160; score[i][2] = 1
&#160; &#160; else
&#160; &#160; &#160; &#160; if score[i-1][1] == score[i][1]
&#160; &#160; &#160; &#160; &#160; &#160; score[i][2] = score[i-1][2]
&#160; &#160; &#160; &#160; else
&#160; &#160; &#160; &#160; &#160; &#160; score[i][2] = score[i-1][2] + 1
&#160; &#160; &#160; &#160; end
&#160; &#160; end
end
















while gets
&#160; &#160; puts score.assoc($_.to_i)[2]
end
score = []
until (t = gets.split(',').map(&:to_i))== [0,0]
&#160; &#160; score << [t[0] , t[1], 0]
end




score.sort!{ |x, y| x[1] <=> y[1] }.reverse!
score.length.times do |i|
# &#160; &#160;p score
&#160; &#160; if i == 0
&#160; &#160; &#160; &#160; score[i][2] = 1
&#160; &#160; else
&#160; &#160; &#160; &#160; if score[i-1][1] == score[i][1]
&#160; &#160; &#160; &#160; &#160; &#160; score[i][2] = score[i-1][2]
&#160; &#160; &#160; &#160; else
&#160; &#160; &#160; &#160; &#160; &#160; score[i][2] = score[i-1][2] + 1
&#160; &#160; &#160; &#160; end
&#160; &#160; end
end




while gets
&#160; &#160; puts score[$_.to_i][2]
end