#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int w[12]={0};
string l[3],r[3],t[3];
bool express(int i){
int Lw=0,Rw=0;
for_each(l[i].begin(),l[i].end(),[&](char c){Lw+=w[c-'A'];});
for_each(r[i].begin(),r[i].end(),[&](char c){Rw+=w[c-'A'];});
if(t[i]=="even"&&Lw==Rw)return true;
if(t[i]=="up" &&Lw> Rw)return true;
if(t[i]=="down"&&Lw< Rw)return true;
return false;
}
int main()
{
char words[][10]={"heavy","light"};
int T,mod;
char ans;
cin>>T;
while(T--){
for(int i=0;i<3;++i){
cin>>l[i]>>r[i]>>t[i];
}
for(int i=0;i<12;++i){
w[i]=1;
if(express(0)&&express(1)&&express(2)){
ans='A'+i;mod=0;w[i]=0;
break;
}
w[i]=-1;
if(express(0)&&express(1)&&express(2)){
ans='A'+i;mod=1;w[i]=0;
break;
}
w[i]=0;
}
printf("%c is the counterfeit coin and it is %s.\n",ans,words[mod]);
}
return 0;
}
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int w[12]={0};
string l[3],r[3],t[3];
class func{
public:
int *var;
func(int *ptr){var=ptr;}
void operator() (char c){
*var+=w[c-'A'];
}
};
bool express(int i){
int Lw=0,Rw=0;
for_each(l[i].begin(),l[i].end(),func(&Lw));
for_each(r[i].begin(),r[i].end(),func(&Rw));
if(t[i]=="even"&&Lw==Rw)return true;
if(t[i]=="up" &&Lw> Rw)return true;
if(t[i]=="down"&&Lw< Rw)return true;
return false;
}
int main()
{
char words[][10]={"heavy","light"};
int T,mod;
char ans;
cin>>T;
while(T--){
for(int i=0;i<3;++i){
cin>>l[i]>>r[i]>>t[i];
}
for(int i=0;i<12;++i){
w[i]=1;
if(express(0)&&express(1)&&express(2)){
ans='A'+i;mod=0;w[i]=0;
break;
}
w[i]=-1;
if(express(0)&&express(1)&&express(2)){
ans='A'+i;mod=1;w[i]=0;
break;
}
w[i]=0;
}
printf("%c is the counterfeit coin and it is %s.\n",ans,words[mod]);
}
return 0;
}