n, f = gets.split.map(&:to_i)
count = Hash.new(0)
n.times do
    a = gets.chomp.split[1..-1]
    a.combination(2).map(&:sort).each {|key| count[key] += 1}
end
pairs = count.select {|key, c| c >= f}.keys.sort
puts pairs.size
pairs.each do |pair|
    puts pair * ' '
end
