#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    int a[1000];
    lp(i,1000){
      a[i]=0;
    }
    int count=0;   
    char x[100];
    lp(i,n){
      cin>>x[i];
    }
    int first=0,second=0,ans=-1;
    char firstmem,ans1;
    lp(i,n){
      a[x[i]-'A']++;
      if(a[x[i]-'A']>n/2) {
	ans=i+1;
	ans1=x[i];
	break;
      }
      if(first==0||first<a[x[i]-'A']){
	first=a[x[i]-'A'];
	firstmem=x[i];
      }
      else if(second<a[x[i]-'A']&&firstmem!=x[i]){
	second=a[x[i]-'A'];
      }
      if(first>second+n-i-1){
	ans=i+1;
	ans1=firstmem;
	break;
      }
    }
    if(ans==-1){
      cout<<"TIE"<<endl;
    }
    else{
      cout<<ans1<<" "<<ans<<endl;
    }
  }
      
  return 0;
}

