public static void main ( String [ ] args ) {
  try {
    Scanner in = new Scanner ( new File ( "C-large.in" ) ) ;
    PrintWriter out = new PrintWriter ( "C-large.out" ) ;
    int tests = in . nextInt ( ) ;
    for ( int test = 1 ;
    test <= tests ;
    test ++ ) {
      String answer = "Case #" + test + ": " ;
      String outfits = "" ;
      int days = 0 ;
      int J = in . nextInt ( ) ;
      int P = in . nextInt ( ) ;
      int S = in . nextInt ( ) ;
      int k = in . nextInt ( ) ;
      for ( int j = 1 ;
      j <= J ;
      j ++ ) {
        for ( int p = 1 ;
        p <= P ;
        p ++ ) {
          for ( int i = 0 ;
          i < S && i < k ;
          i ++ ) {
            outfits += j + " " + p + " " + ( ( ( i + p + j ) % S ) + 1 ) + "\n" ;
            days ++ ;
          }
        }
      }
      answer += days + "\n" + outfits ;
      out . println ( answer ) ;
    }
    in . close ( ) ;
    out . close ( ) ;
  }
  catch ( FileNotFoundException ex ) {
    System . out . println ( "ERROR" ) ;
  }
}

public static void main ( String [ ] args ) { try { Scanner in = new Scanner ( new File ( " C - large . in " ) ) ; PrintWriter out = new PrintWriter ( " C - large . out " ) ; int tests = in . nextInt ( ) ; for ( int test = 1 ; test <= tests ; test ++ ) { String answer = " Case ▁ # " + test + " : ▁ " ; String outfits = " " ; int days = 0 ; int J = in . nextInt ( ) ; int P = in . nextInt ( ) ; int S = in . nextInt ( ) ; int k = in . nextInt ( ) ; for ( int j = 1 ; j <= J ; j ++ ) { for ( int p = 1 ; p <= P ; p ++ ) { for ( int i = 0 ; i < S && i < k ; i ++ ) { outfits += j + " ▁ " + p + " ▁ " + ( ( ( i + p + j ) % S ) + 1 ) + " \n " ; days ++ ; } } } answer += days + " \n " + outfits ; out . println ( answer ) ; } in . close ( ) ; out . close ( ) ; } catch ( FileNotFoundException ex ) { System . out . println ( " ERROR " ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (try_statement body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (string_literal)) right: (identifier)) right: (string_literal)) right: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) right: (identifier))) right: (decimal_integer_literal)))) right: (string_literal)))) (expression_statement (update_expression (identifier))))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (string_literal)) right: (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (catch_clause (catch_formal_parameter (catch_type (type_identifier)) name: (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))))))