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

typedef pair<int, char> Pair;

int n;
set<Pair, greater<Pair> > order;
map<char, int> num;

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    order.clear();
    num.clear();
    for (int i=0; i<26; i++) {
      order.insert(Pair(0, 'A'+i));
      num['A'+i] = 0;
    }

    bool yet = true;
    int ans;
    for (int i=1; i<=n; i++) {
      char c;
      scanf(" %c", &c);

      if (yet) {
        order.erase(Pair(num[c], c));
        num[c] += 1;
        order.insert(Pair(num[c], c));
        auto itr = order.begin();
        int m = itr->first;
        itr++;
        int g = itr->first;
        if (m > g+n-i) {
          ans = i;
          yet = false;
        }
      }
    }

    if (yet) puts("TIE");
    else printf("%c %d\n", order.begin()->second, ans);
  }
}