#include<cstdio>
using namespace std;

int n;
int counter[30];
int maxN, nextN;
char winner;

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (int i = 0; i < 30; i++) counter[i] = 0;
    bool ok = false;
    for (int i = 0; i < n; i++) {
      char c;
      scanf(" %c", &c);
      if (ok) continue;
      int num = (int) c - 'A';
      counter[num]++;
      maxN = counter[0], nextN = 0, winner = 'A';
      for (int j = 1; j <= (int)'Z' - 'A'; j++) {
        if (counter[j] > maxN) winner = (char)j + 'A', nextN = maxN, maxN = counter[j];
        else if (counter[j] > nextN) nextN = counter[j];
      }
      int dif = maxN - nextN, rest = n - i - 1;
      if (n == i + 1) {
        if (dif > 0) printf("%c %d\n", winner, i + 1);
        else printf("TIE\n");
      } else if (dif > rest) {
        printf("%c %d\n", winner, i + 1);
        ok = true;
      }
    }
  }
}

