S=5.times.map{eval"['%s',%d]"%gets.split} A=3.times.map{gets.to_i.times.map{gets.chop}} p S.map{|s,c|$*<