#include
#include<string.h>
using namespace std;
int main()
{
int t,nshots=0,ng1=0,ng2=0,lg1=5,lg2=5,shootout=0,last=0;
char s[22];
while(cin>>s)
{
memset(s,0,sizeof(s));
if(strlen(s)!=20)
break;
for(int j=0;s[j]!='\0';j++)
{
nshots+=1;
if(nshots>10)
{
shootout=1;
}
if(j%2==0)
{
lg1--;
if(s[j]=='1')
ng1++;
}
else
{
lg2--;
if(s[j]=='1')
ng2++;
}
if(shootout&&(nshots%2==0)&&ng1!=ng2)
{
if(ng1>ng2)
{
cout<<"TEAM-A"<<" "<<nshots<<"\n";
break;
}
else
{
cout<<"TEAM-B"<<" "<<nshots<<"\n";
break;
}
}
if(shootout==0)
{
if(ng1+lg1<ng2)
{
cout<<"TEAM-B"<<" "<<nshots<<"\n";
break;
}
if(ng2+lg2<ng1)
{
cout<<"TEAM-A"<<" "<<nshots<<"\n";
break;
}
}
if(nshots==20)
{
cout<<"TIE"<<"\n";
break;
}
}
lg1=5;lg2=5;shootout=0;
nshots=0;ng1=0;ng2=0;
}
return 0;
}