hs={} n,m=gets.split(" ").map{|e| e.to_i} (n+m).times{ name,score=gets.chomp.split(" ") hs[name]=score.to_i } hs.keys.sort.each{|k| puts [k,hs[k]].join(" ") }