#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		int flag=1;
		ll a[30]={};
		rep(i,0,n){
			char c;
			scanf(" %c",&c);
			a[c-'A']++;
			ll M1=0,M2=0;
			ll i1=0,i2=0;
			rep(j,0,26){
				if(M1<a[j]){
					M2=M1;
					i2=i1;
					M1=a[j];
					i1=j;
				}else if(M2<a[j]){
					M2=a[j];
					i2=j;
				}
			}
			if(flag&&M1>M2+(n-1-i)){
				printf("%c %lld\n",'A'+i1,i+1);
				flag=0;
			}
		}
		if(flag)puts("TIE");
	}
}
