while (n = gets.chomp.to_i) != 0
  moments = Array.new(32){[]}

  n.times do
    line = gets.split

    line[2..-1].each{ |t| moments[t.to_i] << line[0] }
  end

  chars = {}
  moments.each do |t|
    p = n - t.size + 1
    t.each{ |name| chars[name] = (chars[name] ? chars[name]+p : p) }
  end

  ans = chars.sort{ |a, b| (a[1] == b[1] ? a[0] <=> b[0] : a[1] <=> b[1]) }[0]

  puts ans.reverse.join(" ")
end