arr=Array.new(1000,0)
while gets
    break if $_=="\n"
    a,n=$_.chomp.split(",").map(&:to_i)
    arr[a]+=1
end
while s=gets
     break if s == nil
    a,n=$_.chomp.split(",").map(&:to_i)
    arr[a]+=1
end
arr.each_with_index do|item,num|
    if (item>=2)
        puts"#{num} #{item}"
    end
end