#include<stdio.h>
int main(void){
    while(1){
        char top, c[200]={0};
        int i, n, alp[26]={0}, first=0, sec=0;
        scanf("%d",&n);
        getchar();
        if(n==0) break;
        for(i=0;i<n;i++){
            scanf("%c",&c[i]);
            getchar();
        }
        for(i=0; i<n; i++){
            alp[c[i]-'A']++;
            if(alp[c[i]-'A'] > first){
                top=c[i];
                first=alp[c[i]-'A'];
            }
            else if(alp[c[i]-'A'] > sec){
                sec=alp[c[i]-'A'];
            }
            if(first-sec > n-i-1){
                break;
            }
        }
        if(first==sec){printf("TIE\n");}
        else{
            printf("%c %d\n",top,i+1);
        }
    }
    return 0;
}

