#include <bits/stdc++.h>

using namespace std;

#define INF 1e9

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    while(1){
        int n;
        cin>>n;

        if(n==0)break;

        int sum[30]={};
        char ans;
        int t=-1;
        bool f=false;

        for(int i=0;i<n;i++){
            char c;
            cin>>c;

            sum[c-'A']++;
            
            int Max1=0,Max2=0;
            char C;

            for(int i=0;i<26;i++){
                if(Max1<sum[i]){
                    Max2=Max1;
                    Max1=sum[i];
                    C='A'+i;
                }
                else if(Max2<sum[i]){
                    Max2=sum[i];
                }
            }
            
            if(Max1>Max2+n-i-1 && !f){
                ans=C;
                t=i+1;
                f=true;
            }

        }

        if(f){
            cout<<ans<<" "<<t<<endl;
        }
        else cout<<"TIE"<<endl;
    }

}
