#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
	while(1){
		int n; cin >> n;
		if(!n) break;
		char ch[101];
		for(int i=0; i<n; i++){
			cin >> ch[i];
		}
		ch[n] = '\0';

		int ma=0; int ma_j=0;
		int next_ma=0, next_ma_j=0;
		int sum[30] ={0};
		for(int i=0; i<n; i++){
			for(int j=0; j<30; j++){
				if(j==ch[i]-'A'){
					sum[j]++;
					if(ma<sum[j]){
						if(ma_j!=j){
							next_ma=ma;
							next_ma_j=ma_j;
						}
						ma=sum[j];
						ma_j=j;
					}
					else if(next_ma<sum[j]){
						next_ma=sum[j];
						next_ma_j=j;
					}
				}
			}

			if(ma>n/2){
				cout << (char)(ma_j+'A') << " " << i+1 << endl;
				break;
			}
			if(ma != next_ma && next_ma+n-i-1<ma){
				cout << (char)(ma_j+'A') << " " << i+1 << endl;
				break;
			}
			if(ma==next_ma && i==n-1){
				cout <<"TIE" << endl;
				break;
			}
		}
		//cout << ch << endl;





	}
	return 0;
}
