#include <iostream>
#include <string>
using namespace std;
struct input{
string left;
string right;
string state;
}in[3];
bool Light(char &ch)
{
for(int i=0;i<3;i++)
{
switch(in[i].state[0])
{
case 'u':
if(in[i].right.find(ch)==string::npos)
return true;
break;
case 'd':
if(in[i].left.find(ch)==string::npos)
return true;
break;
case 'e':
if(in[i].left.find(ch)!=string::npos||in[i].right.find(ch)!=string::npos)
return true;
break;
default:
return false;
}
}
return false;
}
bool Heavy(char &ch)
{
for(int i=0;i<3;i++)
{
switch(in[i].state[0])
{
case 'u':
if(in[i].left.find(ch)==string::npos)
return true;
break;
case 'd':
if(in[i].right.find(ch)==string::npos)
return true;
break;
case 'e':
if(in[i].left.find(ch)!=string::npos||in[i].right.find(ch)!=string::npos)
return true;
break;
default:
return false;
}
}
return false;
}
int main()
{
int n;
cin>>n;
while(n--){
for(int i=0;i<3;i++){
cin>>in[i].left>>in[i].right>>in[i].state;
}
for(char ch='A';ch<='Z';ch++){
if(!Light(ch)){
cout<<ch<<" is the counterfeit coin and it is light.\n";
break;
}
if(!Heavy(ch)){
cout<<ch<<" is the counterfeit coin and it is heavy.\n";
break;
}
}
}
return 0;
}
评论