#include <iostream>

using namespace std;

int main(){
  int n,t;
  int m;
  char v;
  bool ie;
  while(cin >> n,n){
    m=n;
    int a[35]={0};
    int first=30;int second=30;
    ie=false;
    while(n--){
      //cout << n << endl;
      cin >> v;
      t=v-'A';
      a[t]++;
      //cout << n << " " << v << endl;
      if(t!=first&&a[t]>=a[first]){
        second=first;
        first=t;
      }
      else if(t!=first&&t!=second&&a[t]>a[second]){
        second=t;
      }
      if(a[first]>a[second]+n&&ie==false){
        cout << char(first+'A') << " " << m-n << endl;
        ie=true;
      }
      //cout << char(first+'A')<< " " << char(second+'A') << " " << endl;
    }
    if(a[first]==a[second])cout << "TIE" << endl;
    else if(!ie)cout << char(first+'A') << " " << m << endl;
  }
}