#include<stdio.h>
#define MAX 26
typedef struct{
  int name;
  int voted;
} Data;
int main()
{
  char voted;
  int i,m,n;
  int num[MAX];
  Data first,second;
  while(1)
    {
      scanf("%d",&n);
      if(!n) break;
      for(i=0;i<MAX;i++) num[i]=0;
      first=second=(Data){-1,0};
      for(i=0;i<n;i++)
	{
	  scanf(" %c",&voted);
	  m=(int)(voted-'A');
	  num[m]++;
	  if(num[m]==first.name) first.voted=num[m];
	  else if(num[m]==second.name) second.voted=num[m];
	  if(num[m]>first.voted)
	    {
	      if(first.name!=second.name) second=first;
	      first.name=m;
	      first.voted=num[m];      
	    }
	  else if(num[m]>second.voted)
	    {
	      second.name=m;
	      second.voted=num[m];
	    }
	  if(first.voted>second.voted+(n-i-1))
	    {
	      rewind(stdin);
	      break;
	    }
	}
      if(first.voted>second.voted) printf("%c %d\n",first.name+'A',i+1);
      else printf("TIE\n");
    }
  return 0;
}