// Check data for Domiyahtzee: make sure number of cases in line 1
// agrees with actual number of cases; make sure each case is formatted
// properly (13 specification, each of which is either H n1 n2, V n1 n2,
// or S n1, where there is exactly one "S" and 1 <= n1,n2 <= 6).
//
// Does NOT check for duplicate dominos.

import java.util.*;

public class Ccheck {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int numcases = in.nextInt();
    int casenum = 0;
    while (in.hasNext()) {
      casenum++;
      // process one case--should be 13 items, one of which is a singleton
      int sing = 0;
      for (int i = 0; i < 13; i++) {
        String type = in.next();
        if (type.length() != 1 || "HSV".indexOf(type.charAt(0)) < 0)
          System.out.println("Case " + casenum + ": bad type '"+type+"'");
        else {
          int x = in.nextInt();
          if (x < 0 || x > 6)
            System.out.println("Case " + casenum + ": bad value "+x);
          if (!type.equals("S")) {
            int y = in.nextInt();
            if (y < 0 || y > 6)
              System.out.println("Case " + casenum + ": bad value "+y);
          }
          else sing++;
        }
      }
      if (sing != 1)
        System.out.println("Case " + casenum + ": more/less than 1 singleton");
    }
    if (casenum != numcases)
     System.out.println(casenum +" cases in file; should be " + numcases);
  }
}
