#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 100
#define MAX(A,B) ((B) > (A) ? (B) : (A))

static int n;
static char d[N];

static int h['Z' - 'A' + 2];

int main(void) {
  int i, j;

  for (;;) {
    scanf(" %d", &n);
    if (n == 0) break ;
    for (i = 0; i < n; ++i)
      scanf(" %c", &d[i]);
    memset(h, 0, sizeof(h));

    for (i = 0; i < n; ++i) {
      int u = 'Z' + 1, v = 'Z' + 1;
      
      h[d[i] - 'A'] += 1;
      for (j = 'A'; j <= 'Z'; ++j) {
        if (h[u - 'A'] < h[j - 'A']) {
          v = u;
          u = j;
        } else if (h[v - 'A'] < h[j - 'A']) {
          v = j;
        }
      }
      if (h[v - 'A'] + n - i - 1 < h[u - 'A']) {
        printf("%c %d\n", u, i + 1);
        break ;
      }
    }
    if (i == n)
      puts("TIE");
  }

  return EXIT_SUCCESS;
}