#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        vector<char> C(n);
        for(int i = 0; i < n; ++i) cin >> C[i];
        vector<int> V(26,0);
        string ans = "TIE";
        bool g = false;
        char a = '?';
        for(int i = 0; i < n; ++i){
            int c = C[i] - 'A';
            ++V[c];

            bool f = true;
            for(int k = 0; k < 26; ++k){
                f = true;
                for(int j = 0; j < 26; ++j){
                    if(j == k) continue;
                    f &= (V[j]+(n-1-i)) < V[k];
                }
                if(f){
                    a = 'A' + k;
                    break;
                }
            }
            if(f){
                g = true;
                ans = to_string(i+1);
                break;
            }
        }
        if(g) cout << a << " ";
        cout << ans << endl;
    }
}

