#include <bits/stdc++.h>
using namespace std;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int dp[11][156];

string unj(string s) {
    int n = s.length();
    return s.substr(n - 1) + s.substr(0, n - 1);
}

string unc(string s) {
    int n = s.length();
    return s.substr(1) + s.substr(0, 1);
}

string une(string s) {
    int n = s.length();
    if (s.size() & 1) {
        return s.substr(n / 2 + 1) + s.substr(n / 2, 1) + s.substr(0, n / 2);
    } else {
        return s.substr(n / 2) + s.substr(0, n / 2);
    }
}

string una(string s) { return string(s.rbegin(), s.rend()); }

string unp(string s) {
    for (char &c : s)
        if (isdigit(c))
            c = '0' + (c - '0' + 9) % 10;
    return s;
}

string unm(string s) {
    for (char &c : s)
        if (isdigit(c))
            c = '0' + (c - '0' + 1) % 10;
    return s;
}

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    for (;;) {
        int n;
        cin >> n;
        if (!n)
            break;

        map<char, int> m;
        set<pair<int, char>> s;
        vector<char> v(n);
        rep(i, 0, n) cin >> v[i];

        rep(i, 0, n) {
            int left = n - 1 - i;
            s.erase({m[v[i]], v[i]});
            m[v[i]]++;
            s.insert({m[v[i]], v[i]});

            int fst = s.rbegin()->first;
            int snd = (s.size() >= 2 ? next(s.rbegin())->first : 0) + left;

            if (fst > snd) {
                cout << s.rbegin()->second << " " << i + 1 << endl;
                goto nxtloop;
            }
        }
        if (s.rbegin()->first > next(s.rbegin())->first) {
            cout << s.rbegin()->second << " " << n << endl;
        } else {
            cout << "TIE" << endl;
        }
    nxtloop:
        void(0);
    }
}



Measured memory_bytes: 3164