#include <iostream> #include <string> using namespace std; string Left[3], Right[3], result[3]; bool dealLight(char& ch) { for(int i = 0; i < 3; ++i) { switch(result[i][0]) {//u -> up,d -> down,e -> even case 'u': if(Right[i].find(ch) == string::npos) return true; break; case 'd': if(Left[i].find(ch) == string::npos) return true; break; case 'e': if(Left[i].find(ch) != string::npos || Right[i].find(ch) != string::npos) return true; break; } } return false; } bool dealHeavy(char& ch) { for(int i = 0; i < 3; ++i) { switch(result[i][0]) {//u -> up,d -> down,e -> even case 'u': if(Left[i].find(ch) == string::npos) return true; break; case 'd': if(Right[i].find(ch) == string::npos) return true; break; case 'e': if(Left[i].find(ch) != string::npos || Right[i].find(ch) != string::npos) return true; break; } } return false; } int main() { int N; scanf("%d", &N); while(N--) { for(int i = 0; i < 3; ++i) cin >> Left[i] >> Right[i] >> result[i]; for(char ch = 'A'; ch <= 'L'; ++ch) { if(!dealLight(ch)) { printf("%c is the counterfeit coin and it is light./n", ch); break; } if(!dealHeavy(ch)) { printf("%c is the counterfeit coin and it is heavy./n", ch); break; } } } return 0; } //穷举A~L之间的每一个字符,对于每一个字符遍历这三句话, //进行判断,若判断为false,则表示以寻找到特殊这个字符 //具体解题思路: //在up的right && down的left(heavy), //or 在up的left && down的right(light), //不在even中的字符为特殊字符. //否则会出现>=2个特殊字符.