#include <bits/stdc++.h>

using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		vector<int> v(26,0);
		int i;
		vector<char> c(n);
		for(i=0;i<n;i++){
			cin >> c[i];
		}
		for(i=0;i<n;i++){
			//cout << "turn: " << i << endl;
			v[c[i] - 'A']++;
			int max_index = distance(v.begin(), max_element(v.begin(),v.end()));
			int j;
			for(j=0;j<26;j++){
				if(max_index != j && v[max_index] <= v[j] + (n-i-1)){
					break;
				}
			}
			if(j==26){
				cout << (char)('A' + max_index) << " " << i+1 << endl;
				break;
			}
		}
		if(i==n){
			cout << "TIE" << endl;
		}
	}
	
	return 0;
}