// Check data for Inspectors: make sure number of cases in line 1
// agrees with actual number of cases; make sure each case is formatted
// properly: line containing n, followed by n-1 lines with the appropriate
// number of data values in the appropriate range.

import java.util.*;

public class Echeck {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int numcases = Integer.parseInt(in.nextLine());
    int casenum = 0;
    while (in.hasNext()) {
      casenum++;
      // process one case--
      int n = Integer.parseInt(in.nextLine());
      if (n < 2 || n > 100) {
        System.out.println("Value of n is illegal: " + n);
      }
      for (int i = n-1; i >= 1; i--) {
        String[] token = in.nextLine().split(" ");
        if (token.length != i) {
          System.out.println("Case " + casenum + ": line should have " + i +
              " values, but instead has " + token.length);
        }
        for (String s:token) {
          int temp = Integer.parseInt(s);
          if (temp < 1 || temp > 1000)
            System.out.println("Case " + casenum + ": illegal distance " + temp);
        }
      }
    }
    if (casenum != numcases)
     System.out.println(casenum +" cases in file; should be " + numcases);
  }
}
