import java.util.Scanner;

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val ans = mutableListOf<String>()
	while (true) {
		val n = scanner.nextInt()
		if (n==0) break
		val map = mutableMapOf<Char, Int>()
		var max = Pair('-', 0)
		var second = 0
		var win: Pair<Char, Int>? = null
		for (i in 1..n) {
			val c = scanner.next().toCharArray()[0]
			map[c] = map.getOrElse(c){0} + 1
			if (map[c]!! > max.second) max = Pair(c, map[c]!!)
			else if (map[c]!! > second) second = map[c]!!
			val r = n-i
			if (max.second > second+r) {
				win = Pair(max.first, i)
				repeat(r) {scanner.next()}
				break
			}
		}
		if (win!=null) ans.add("${win.first} ${win.second}")
		else ans.add("TIE")
	}
	ans.forEach { println(it) }
}
