while n = gets.to_i
  break if n == 0
  h1 = Hash.new
  n.times do
    a = gets.split
    s = a.shift
    h1[s] = a.map(&:to_i)
    h1[s].shift
  end
  t = Hash.new(0)
  h1.each_value do |x|
    x.each { |v| t[v] += 1 }
  end
  h2 = Hash.new
  h1.each do |name, i|
    h2[name] = 0
    i.each { |j| h2[name] += n-t[j]+1 }
  end
  h2.sort!
  ans = h2.sort_by { |k, v| v }.shift
  puts ans[1].to_s << " " << ans[0]
end