#include<iostream>
using namespace std;

int main(){
 while(true){
  int n;
  cin >> n;
  if(n==0) break;
 
  char c[n];
  for(int i=0; i<n; i++){
   cin >> c[i];
  }
 
  int can[26] = {0}; //????£????(candidate)????\¨??°
  
  for(int i=0; i<n; i++){
   can[(int)(c[i]-'A')]++;
   
   int max1 = -1; //??????
   int max2 = -1; //??????

   //A~Z???????\¨??°???????????????
   for(int j=0; j<26; j++){
    if(can[j]>max1){
     max2 = max1;
     max1 = can[j];
    }else if(can[j]>max2){
     max2 = can[j];
    }
   }

   //????????????????????????????\¨??°???????????????
   if(max1-max2>n-(i+1)){
    for(int j=0; j<26; j++){
     if(can[j]==max1){
      cout << (char)(j+'A') << ' ';
      break;
     }
    }
    cout << (i+1) << endl;
    break;
   }

   //???????????§????\¨????????´???
   if(i==n-1){
    cout << "TIE" << endl;
    break;
   }
  }
 }
 
 return 0;
}