#include <iostream>
#include <map>
using namespace std;;

int main(){
	int n;
	cin >> n;
	char tmp;

	while(n != 0){

		map <char,int> c;
		map <char,int>::iterator ic;
		int flag = 0;
		int flag2 = 0;
		char max;
		char second_max;

		cin >> max;
		second_max = max;
		c[max]++;

		if(n == 1){
			cout << max << " " << 1 << endl;
			flag = 1;
		}else{
			for(int i = 2 ; i <= n ; i++){
				cin >> tmp;
				c[tmp]++;
				if(tmp != max){
					if(flag2 == 0){
						second_max = tmp;
						flag2 = 1;
					}else if(c[max] <= c[tmp]){
						second_max = max;
	 					max = tmp;
					}else if(c[second_max] < c[tmp]){
						second_max = tmp;
					}
				}

				if((flag == 0 && c[max] - c[second_max] > n-i) || (flag2 == 0 && n - c[max] < c[max] )){
				  cout << max << " " << i << endl;
					flag = 1;
					flag2 = 1;
				}
			}
		}

		if(flag == 0){
			cout << "TIE" << endl;
		}

		for(ic = c.begin() ; ic != c.end() ; ic++){
		}
		cin >> n;
	}
	return 0;
}

