loop do
  n = gets.to_i
  break if n == 0
  c = gets.chomp.split

  if n == 1
    puts "#{c[0]} 1"
    next
  end

  res = []
  solved = false
  c.each_with_index do |ch, i|
    res[ch.ord-65] ||= 0
    res[ch.ord-65] += 1
    rest = c.size - i - 1

    res = res.map {|a| a ? a : 0 }
    t = res.sort
    if t[-2] && t[-1] - rest > t[-2] # t[-1] == t[-2] ?????´?????????????????§??????(????????????)
      puts "#{(res.index(t[-1])+65).chr} #{i+1}"
      solved = true
      break
    end
  end

  puts "TIE" unless solved
end