#include <stdio.h>#include <stdlib.h>#include <string.h>char left[3][7], right[3][7];char result[3][6];int a[15];int w;int judge(char ch){ int r1, r2; int i; int a[3]; for (i = 0; i < 3; ++i) { r1 = strcmp(result[i], "even"); r2 = strcmp(result[i], "up"); if (strchr(left[i], ch) != NULL) { if (r1 == 0) return 0; else if (r2 == 0) a[i] = 1; else a[i] = -1; } else if (strchr(right[i], ch) != NULL) { if (r1 == 0) return 0; else if (r2 == 0) a[i] = -1; else a[i] = 1; } else { if (r1 != 0) return 0; a[i] = 3; } } if (a[0] != 3) w = a[0]; else if (a[1] != 3) w = a[1]; else if (a[2] != 3) w = a[2]; for (i = 0; i < 3; ++i) { if (a[i] != 3 && a[i] != w) { return 0; } } return 1; } int main(void) { int n; int i; char *p; char ch; int r; scanf("%d%*c", &n); while (n--) { memset(a, 0, sizeof(a)); for (i = 0; i < 3; ++i) { scanf("%s%s%s", left[i], right[i], result[i]); if (strcmp (result[i], "even") == 0) { p = left[i]; while (*p != ' ') { a[*p-'A'] = 1; ++p; } p = right[i]; while (*p != ' ') { a[*p-'A'] = 1; ++p; } } } for (ch = 'A'; ch <= 'L'; ++ch) { if (a[ch-'A'] == 1) continue; r = judge(ch); if (r == 1) { if (w > 0) { printf("%c is the counterfeit coin and it is heavy.n", ch); } else { printf("%c is the counterfeit coin and it is light.n", ch); } break; } } } return 0; }