n, f = gets.chomp.split.map(&:to_i)
h = Hash.new{|h, k| h[k] = Hash.new{|h2, k2| h2[k2] = 0}}
n.times{
    items = (gets.chomp.split)[1..-1]
    items.combination(2){|x, y|
        x2, y2 = [x, y].sort
        h[x2][y2] += 1}
}
arr = []
h.each{|k, v| v.each{|k2, v2| arr << [k, k2] if v2 >= f}}
arr.sort!
puts arr.length
arr.each{|item| puts item.join(" ")}
