#include <bits/stdc++.h>

using namespace std;

int n[1600]={};
char c[1600][150] = {};



int main(){
    int s = 0;
    while(1){
        scanf("%d",&n[s]);
        if(n[s] == 0) break;
        for(int i=0;i<n[s];i++) cin >> c[s][i] ;
        s++;
    }
    int times = s;
    int alpha[26]={};
    
    for(int i=0;i<times;i++){
        int first = 0,second = 0;
        int first_alpha = 0;
        for(int j=0;j<26;j++) alpha[j] = 0;
        for(int j=0;j<n[i];j++){
            int al = c[i][j] - 'A';
            alpha[al]++;
            if(alpha[al] > first) {
                first = alpha[al];
                first_alpha = 'A' + al;
            }
            else{
                if(alpha[al] > second){
                    second = alpha[al];
                }
            }
           if(first - second > n[i] - (j+1) ){
                printf("%c %d\n",first_alpha,j+1);
                break;
            }else if(first == second && j == n[i]-1){
                cout << "TIE" << endl;
            }
        }
    }
}
