#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n;
    while(cin>>n&&n){
        int sum[26]={};
        string ans="TIE"; int ansN=0;
        pair<int,int> top;
        rep(i,n){
            char c; cin>>c;
            if(!ansN){
                sum[c-'A']++;
                if(sum[c-'A']>top.second){
                    top=make_pair(c-'A',sum[c-'A']);
                }
                bool flg=1;
                rep(j,26){
                    if(top.first!=j){
                        if(top.second<=sum[j]+n-i-1) flg=0;
                    }
                }
                if(flg){
                    ansN=i+1;
                    char x=top.first+'A';
                    ans=x;
                }
            }
        }
        cout<<ans;
        if(ansN) cout<<" "<<ansN;
        cout<<endl;
    }
    return 0;
}

