#include<stdio.h>
#include<algorithm>
using namespace std;
int n,m,k,a[22][22],fail,q,i,j,M[22222][22],fi;
char dump[1025];
long long R;
int main(){
freopen("cowrun.in","r",stdin);
freopen("cowrun.out","w",stdout);
scanf("%d%d%d",&n,&m,&k);gets(dump);gets(dump);
for(i=0;i<n;i++)for(j=0;j<8;j++)scanf("%d",&a[i][j]);
for(i=0;i<(1<<n);i++)for(j=0;j<n;j++)if(i&(1<<j))M[i][j]=1;
for(i=0;i<(1<<n);i++){ //FJ's choices
fail=0;
for(j=0;j<(1<<n);j++){
R=0;
for(q=0;q<n;q++){
fi=((M[i][q]==0)<<2)+((M[j][q]==0)<<1);
R+=(R*(long long)a[q][fi])+a[q][fi+1];if(R>=m)R%=m;
}
if(R>k&&(m-R)>k){fail=1;break;}
}
if(!fail){
for(j=0;j<n;j++)if(i&(1<<j))putchar('T');else putchar('B');
puts("");
return 0;
}
}
puts("something went wrong");
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbixtLGssYVsyMl1bMjJdLGZhaWwscSxpLGosTVsyMjIyMl1bMjJdLGZpOwpjaGFyIGR1bXBbMTAyNV07CmxvbmcgbG9uZyBSOwppbnQgbWFpbigpewoJZnJlb3BlbigiY293cnVuLmluIiwiciIsc3RkaW4pOwoJZnJlb3BlbigiY293cnVuLm91dCIsInciLHN0ZG91dCk7CglzY2FuZigiJWQlZCVkIiwmbiwmbSwmayk7Z2V0cyhkdW1wKTtnZXRzKGR1bXApOwoJZm9yKGk9MDtpPG47aSsrKWZvcihqPTA7ajw4O2orKylzY2FuZigiJWQiLCZhW2ldW2pdKTsKCWZvcihpPTA7aTwoMTw8bik7aSsrKWZvcihqPTA7ajxuO2orKylpZihpJigxPDxqKSlNW2ldW2pdPTE7Cglmb3IoaT0wO2k8KDE8PG4pO2krKyl7IC8vRkoncyBjaG9pY2VzCgkJZmFpbD0wOwoJCWZvcihqPTA7ajwoMTw8bik7aisrKXsKCQkJUj0wOwoJCQlmb3IocT0wO3E8bjtxKyspewoJCQkJZmk9KChNW2ldW3FdPT0wKTw8MikrKChNW2pdW3FdPT0wKTw8MSk7CgkJCQlSKz0oUioobG9uZyBsb25nKWFbcV1bZmldKSthW3FdW2ZpKzFdO2lmKFI+PW0pUiU9bTsKCQkJfQoJCQlpZihSPmsmJihtLVIpPmspe2ZhaWw9MTticmVhazt9CgkJfQoJCWlmKCFmYWlsKXsKCQkJZm9yKGo9MDtqPG47aisrKWlmKGkmKDE8PGopKXB1dGNoYXIoJ1QnKTtlbHNlIHB1dGNoYXIoJ0InKTsKCQkJcHV0cygiIik7CgkJCXJldHVybiAwOwoJCX0KCX0KCXB1dHMoInNvbWV0aGluZyB3ZW50IHdyb25nIik7CglyZXR1cm4gMDsKfQo=