/*Counterfeit Dollar
2008-08-04 20:48:27 Accepted 1184 C++ 00:00.00 840K 天将降大任于我
直接查找哪个有问题的即可
*/
#include<iostream>
#include<string>
using namespace std;
struct node
{
string s1,s2;
int cmp;
}a[3];
int w[12];
int check() //查找是否有问题,左边全部加起来,右边全部加起来,看左跟右关系
{
for(int i=0;i<3;i++)
{
string str1=a[i].s1,str2=a[i].s2;
int x=0,y=0; int j;
for(j=0;j<str1.length();j++) x+=w[str1[j]-'A'];
for(j=0;j<str2.length();j++) y+=w[str2[j]-'A'];
if(!((x<y&&a[i].cmp==-1)||(x==y&&a[i].cmp==0)||(x>y&&a[i].cmp==1))) return 0;
}
return 1;
}
int main()
{
int n,i,j;string s;
cin>>n;
for(j=1;j<=n;j++)
{
for(i=0;i<3;i++)
{
cin>>a[i].s1>>a[i].s2>>s;
if(s=="even") a[i].cmp=0;
else if(s=="up") a[i].cmp=1;
else a[i].cmp=-1;
}
for(i=0;i<12;i++) //从A到L一个一个查找,没问题的就pass,有问题的就输出
{
memset(w,0,sizeof(w));
w[i]=1;
if(check())
{
cout<<char(i+'A')<<" is the counterfeit coin and it is heavy."<<endl;
break;
}
w[i]=-1;
if(check())
{
cout<<char(i+'A')<<" is the counterfeit coin and it is light."<<endl;
}
}
}
return 0;
}
心难泰,世风坏,旧时正气今何在?正义寡,人情薄,闻道虽多,茅塞不开。怪!怪!怪!
空等待,几多载,冲出重围人心快!暴雨打,狂风袭,任他折磨,此志难改。耐!耐!耐!