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

int main(){
  int n, t, i;
  
  while(1){
    
    int a[30] = {}, max = 28, s  =29, ans = 0;
    char c;
    
    cin>>n;
    if(n == 0) break;

    for(i = 1; i <= n; i++){
      cin>>c;
      
      t = c -'A';

      a[t]++;
      

      
      if(a[t] >= a[max]){
		if(max != t) {
			s = max; 
			max = t;
		}
      }else if (a[t] > a[s]) {
		s = t; 
      }
      
        if(a[max] > a[s] + n - i && ans == 0)
       	ans = i;
      
    }
      c = max + 'A';

      if(a[max] == a[s]) cout<<"TIE"<<endl;
      else cout<<c<<" "<<ans<<endl;
    
  }
	return 0;
}

