public static void main ( String [ ] args ) {
  try {
    String fileName = "C-large" ;
    Scanner in = new Scanner ( new File ( fileName + ".in" ) ) ;
    PrintWriter out = new PrintWriter ( fileName + ".out" ) ;
    int numberOfTestCases = in . nextInt ( ) ;
    for ( int caseNum = 1 ;
    caseNum <= numberOfTestCases ;
    caseNum ++ ) {
      int J = in . nextInt ( ) ;
      int P = in . nextInt ( ) ;
      int S = in . nextInt ( ) ;
      int k = in . nextInt ( ) ;
      int dayCount = 0 ;
      String result = "" ;
      for ( int j = 1 ;
      j <= J ;
      j ++ ) {
        for ( int p = 1 ;
        p <= P ;
        p ++ ) {
          for ( int i = 0 ;
          i < S && i < k ;
          i ++ ) {
            dayCount ++ ;
            int a = ( ( ( i + p + j ) % S ) + 1 ) ;
            result += j + " " + p + " " + a + "\n" ;
          }
        }
      }
      out . println ( "Case #" + caseNum + ": " + dayCount + "\n" + result . substring ( 0 , result . length ( ) - 1 ) ) ;
    }
    in . close ( ) ;
    out . close ( ) ;
  }
  catch ( Exception ex ) {
    ex . printStackTrace ( ) ;
  }
}

public static void main ( String [ ] args ) { try { String fileName = " C - large " ; Scanner in = new Scanner ( new File ( fileName + " . in " ) ) ; PrintWriter out = new PrintWriter ( fileName + " . out " ) ; int numberOfTestCases = in . nextInt ( ) ; for ( int caseNum = 1 ; caseNum <= numberOfTestCases ; caseNum ++ ) { int J = in . nextInt ( ) ; int P = in . nextInt ( ) ; int S = in . nextInt ( ) ; int k = in . nextInt ( ) ; int dayCount = 0 ; String result = " " ; for ( int j = 1 ; j <= J ; j ++ ) { for ( int p = 1 ; p <= P ; p ++ ) { for ( int i = 0 ; i < S && i < k ; i ++ ) { dayCount ++ ; int a = ( ( ( i + p + j ) % S ) + 1 ) ; result += j + " ▁ " + p + " ▁ " + a + " \n " ; } } } out . println ( " Case ▁ # " + caseNum + " : ▁ " + dayCount + " \n " + result . substring ( 0 , result . length ( ) - 1 ) ) ; } in . close ( ) ; out . close ( ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } }
(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: (string_literal))) (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 (binary_expression left: (identifier) right: (string_literal)))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (binary_expression left: (identifier) right: (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: (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)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (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 (update_expression (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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))))) (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: (identifier)) right: (string_literal)))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal)) right: (identifier)) right: (string_literal)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))))))))) (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: (identifier) name: (identifier) arguments: (argument_list))))))))