n, m = read_line.split.map(&.to_i) a = read_line.split.map(&.to_i) cnt = Hash(Int32, Int32).new(0) a.each do |i| cnt[i] += 1 end (1..m).each do |i| puts [i, cnt[i]].join(' ') end