#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0) {
      break;
    }

    int ans = -1;
    vector<int> man(26, 0);
    vector<char> c(n);
    for(int i=0; i<n; i++){
      cin >> c[i];
    }

    int max;
    for(int i=0; i<n; i++){
      man[c[i]-'A']++;
      vector<int> temp = man;
      sort(temp.begin(), temp.end(), greater<int>());
      /*
      int temp = 0, temp2 = 0;
      int ti, ti2;
      for (int j = 0; j < 26; j++) {
	if (man[j] >= temp) {
	  temp2 = temp;
	  temp = man[j];

	  ti2 = ti;
	  ti = j;
	}else if(man[j] > temp2){
	  temp2 = man[j];
	  ti2 = j;
	}
      }
      */

      if(temp[0] > temp[1] + (n-i-1)){
	max = temp[0];
	ans = i;
	break;
      }
    }

    int ti;
    for(int i=0; i<26; i++){
      if(man[i] == max)
	ti = i;
    }

    if(ans == -1)
      cout << "TIE" << endl;
    else   
      cout << (char)(ti+'A') << " " << ans+1 <<endl;
  }

  return 0;
}