#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=10000;
const ll INF=1000000010;
const ll LINF=1000000000000000010;
const int MAX=2010;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int main(){
	int n;
	while(cin>>n,n){
		char c[110];
		for(int i=0;i<n;i++){
			cin>>c[i];
		}
		int a[26]={};
		bool ff=false;
		char ans1;int ans2;
		for(int i=0;i<n;i++){
			a[c[i]-'A']++;
			for(int j=0;j<26;j++){
				bool f=true;
				for(int k=0;k<26;k++){
					if(j==k)continue;
					if(a[j]<=a[k]+(n-1-i)){
						f=false;
						break;
					}
				}
				if(f){
					ans1='A'+j;
					ans2=i+1;
					ff=true;
					break;
				}
			}
			if(ff){
				break;
			}
		}
		if(ff){
			cout<<ans1<<" "<<ans2<<endl;
		}else{
			cout<<"TIE"<<endl;
		}
	}
	return 0;
}

