#include<iostream>
using namespace std;

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0){break;}
        int table[26]={0};
        char chara[n+1];
        int maxi1=0;
        int maxi2=0;
        char max_chara[2];
        for(int i=0;i<n;i++)cin>>chara[i];
        for(int t=0;t<n;t++){
            table[chara[t]-'A']++;
            if(table[chara[t]-'A']>maxi1){
                maxi1=table[chara[t]-'A'];
                max_chara[0]=chara[t];
            }
            else if(table[chara[t]-'A']>maxi2)maxi2=table[chara[t]-'A'];
            if(maxi1-maxi2 >= n-t){
                cout<<max_chara[0]<<" "<<t+1<<endl;
                break;
            }
            if(t==n-1)
                if(maxi1==maxi2)
                    cout<<"TIE"<<endl;
        }
    }
}
