#include <iostream>
#include<cstring>
#include<cstring>
using namespace std;
char Left[3][7]; //3次天平左边的重量
char Right[3][7]; //3次天平右边的重量
char result[3][7]; //结果
bool IsFake(char c,bool light); //bool类型进行假设
int main()
{
int t;
cin>>t;
while(t--)
{
for(int i=0;i<3;i++)
cin>>Left[i]>>Right[i]>>result[i];
for(char c='A';c<='L';c++)
{
if(IsFake(c,true))
{
cout<<c<<" is the counterfeit coin and it is light.\n";
break;
}
else if(IsFake(c,false))
{
cout<<c<<" is the counterfeit coin and it is heavy.\n";
break;
}
}
}
}
bool IsFake(char c,bool light)
{
for(int i=0;i<3;i++)
{
char *pLeft,*pRight; //用指针存储天平左右两边的数据
if(light)
{
pLeft=Left[i];
pRight=Right[i];
}
else //如果light为假,左右调换
{
pLeft=Right[i];
pRight=Left[i];
}
switch(result[i][0]) //对结果中第一个字符进行判断
{
case 'u':
if(strchr(pRight,c)==NULL) //在pRight中查找c代表的元素
return false;
break;
case 'e':
if(strchr(pLeft,c)||strchr(pRight,c))
return false;
break;
case 'd':
if(strchr(pLeft,c)==NULL)
return false;
break;
}
}
return true;
}
char Left[3][7]; //3次天平左边的重量
char Right[3][7]; //3次天平右边的重量
char result[3][7]; //结果
bool IsFake(char c,bool light); //bool类型进行假设
int main()
{
int t;
cin>>t;
while(t--)
{
for(int i=0;i<3;i++)
cin>>Left[i]>>Right[i]>>result[i];
for(char c='A';c<='L';c++)
{
if(IsFake(c,true))
{
cout<<c<<" is the counterfeit coin and it is light.\n";
break;
}
else if(IsFake(c,false))
{
cout<<c<<" is the counterfeit coin and it is heavy.\n";
break;
}
}
}
}
bool IsFake(char c,bool light)
{
for(int i=0;i<3;i++)
{
char *pLeft,*pRight; //用指针存储天平左右两边的数据
if(light)
{
pLeft=Left[i];
pRight=Right[i];
}
else //如果light为假,左右调换
{
pLeft=Right[i];
pRight=Left[i];
}
switch(result[i][0]) //对结果中第一个字符进行判断
{
case 'u':
if(strchr(pRight,c)==NULL) //在pRight中查找c代表的元素
return false;
break;
case 'e':
if(strchr(pLeft,c)||strchr(pRight,c))
return false;
break;
case 'd':
if(strchr(pLeft,c)==NULL)
return false;
break;
}
}
return true;
}