#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main(){
    int n;
    while(cin >> n && n){
        map<char, int> mp;
        int i;
        char cc[110];
        set<char> sss;
        sss.insert('1');
        rep(i, n){
            string s;
            cin >> s;
            cc[i] = s[0];
            sss.insert(cc[i]);
        }

        for(i = 0; i < n; ++i){
            char c = cc[i];
            ++mp[c];
            vector<char> v(all(sss));
            sort(all(v), [&](char a, char b){
                    return mp[a] > mp[b];
                });
            if(mp[v[0]] > mp[v[1]] + n-i-1){
                cout << v[0] << ' ' << i+1  << '\n';
                break;
            }
        }
        if(i == n){
            cout << "TIE" << endl;
        }
    }
}