public class Main{
public static int status[]=new int[12];
public static String left[]=new String[3];
public static String right[]=new String[3];
public static String result[]=new String[3];
private static boolean Balanced() {
// TODO Auto-generated method stub
int i,k,leftw,rightw;
for(i=0;i<3;i++){
leftw=rightw=0;
int len = left[i].length();
for(k=0;k<len;k++){
//计算左边的重量
leftw+=status[left[i].charAt(k)-'A'];
//计算右边的重量,需要添加代码
rightw+=status[right[i].charAt(k)-'A'];
}
//如果左边的重量大于右边的重量,而相应的结果却不是up,说明枚举的不符合要求
if(leftw>rightw && !result[i].equals("up")){
return false;
}
//如果左边的重量等于右边的重量,而相应的结果却不是even,说明枚举的不符合要求
if(leftw==rightw && !result[i].equals("even")){
return false;
}
//如果左边的重量<于右边的重量,而相应的结果却不是down,说明枚举的不符合要求
if(leftw<rightw && !result[i].equals("down")){
return false;
}
}
return true;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.nextLine());
for(int i=0;i<n;i++){
for(int j=0;j<3;j++){
String str = sc.nextLine();
String[] split = str.split(" ");
//将左边放置情况存入
left[j]=split[0];
//将右边放置情况存入
right[j]=split[1];
//将结果存入result字符串数组,需写代码
result[j]=split[2];
}
//开始检查
//初始化所有的银币为真
for(int j=0;j<12;j++){
status[j]=0;
}
//开始枚举
int j;
for( j=0;j<12;j++){
//假设第j枚银币为-1
status[j]=-1;
if(Balanced()){
break;
}
//假设第j枚银币为1
status[j]=1;
if(Balanced()){
break;
}
status[j]=0;
}
String ans=status[j]>0 ? "heavy." :"light.";
System.out.print((char)('A'+j)+" is the counterfeit coin and it is "+ans+"\n");
}
}
}