#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI       3.1415926535897932384626433832795028841971
#define INF 1000000000
#define EPS      1e-10
#define MOD      1000003
#define HOGE 100000
#define HUGA 100000
using namespace std;
typedef long long ll;
typedef pair<double,double> P;
typedef pair<double,P> PQ;

int n;
int cnt[26];
int num[26];
char cha[100];

void solve(){
    memset(cnt,0,sizeof(cnt));
    rep(i,n) cin >> cha[i];
    rep(i,n){
        int id = cha[i]-'A';
        cnt[id]++;
        rep(j,26) num[j] = cnt[j];
        sort(num,num+26,greater<int>());
        if(num[0] > num[1]+n-i-1){
            rep(j,26){
                if(cnt[j] == num[0]){
                    char out;
                    out = 'A'+j;
                    cout << out << " " << i+1 << endl;
                    return;
                }
            }
        }
    }
    cout << "TIE" << endl;
}

int main(){
    while(cin >> n){
        if(n == 0) break;
        solve();
    }
}