last = {}
until gets.chomp == ''
    last[$_.chomp.split(',')[0]] = (last[$_.chomp.split(',')[0]].nil?)?1:(last[$_.chomp.split(',')[0]]+1)
end

this = {}
while gets
    this[$_.chomp.split(',')[0]] = (this[$_.chomp.split(',')[0]].nil?)?1:(this[$_.chomp.split(',')[0]]+1)
end

last.merge(this){|key, old, new| old + new}.select{|key,val| last.key?(key) && this.key?(key)}.to_a.sort{|x,y|x[0].to_i<=>y[0].to_i}.each { |x| puts x*' ' }