#include<stdio.h>

int main(void)
{
  int i,j,k,n,temp,temp1;
  int m1,m2;
  char in[2], chartemp;
  int a[26];

  while(scanf("%d",&n))
    {
      for(i=0;i<26;i++)
	{
	  a[i] = 0;
	}
      if(n==0)
	break;
      else
	{
	  k = 0;
	  for(i=0;i<n;i++)
	    {
	      scanf("%s",in);
	      temp = in[0];
	      a[temp-65]++;
	      m1 = 0;
	      for(j=0;j<26;j++)
		{
		  if(m1<=a[j])
		    {
		      m1 = a[j];
		      temp1 = j;
		    }
		}
	      m2 = 0;
	      for(j=0;j<26;j++)
		{
		  if(m2<=a[j]&&j!=temp1)
		    {
		      m2 = a[j];
		    }
		}
	      if((m1-m2)>n-(i+1)&&k==0)
		k = i+1;
	    }
	  chartemp = temp1;
	  if(k!=0) printf("%c %d\n",chartemp+65,k);
	  //else if(k==0&&m1!=m2) printf("%c %d\n",chartemp+65,n);
	  else printf("TIE\n");
	}
    }
  return 0;
}