public static void main ( String [ ] arg ) {
  Scanner sc = new Scanner ( System . in ) ;
  int TT = sc . nextInt ( ) ;
  for ( int ii = 1 ;
  ii <= TT ;
  ++ ii ) {
    int N = sc . nextInt ( ) ;
    int P = sc . nextInt ( ) ;
    int [ ] M = new int [ 5 ] ;
    for ( int i = 0 ;
    i < N ;
    ++ i ) {
      int G = sc . nextInt ( ) ;
      M [ G % P ] ++ ;
    }
    int ans = 1 + M [ 0 ] ;
    if ( P == 2 ) {
      ans += M [ 1 ] / 2 ;
      if ( M [ 1 ] % 2 == 0 ) ans -- ;
    }
    else if ( P == 3 ) {
      int min = Math . min ( M [ 1 ] , M [ 2 ] ) ;
      int left = Math . max ( M [ 1 ] , M [ 2 ] ) - min ;
      if ( left % 3 == 0 ) ans -- ;
      left /= 3 ;
      ans += min + left ;
    }
    else if ( P == 4 ) {
      while ( M [ 2 ] >= 2 ) {
        ans ++ ;
        M [ 2 ] -= 2 ;
      }
      while ( M [ 1 ] > 0 && M [ 3 ] > 0 ) {
        ans ++ ;
        M [ 1 ] -- ;
        M [ 3 ] -- ;
      }
      if ( M [ 2 ] == 1 ) {
        if ( M [ 1 ] % 4 >= 2 ) {
          ans ++ ;
          M [ 1 ] -= 2 ;
          M [ 2 ] -- ;
        }
        else if ( M [ 3 ] % 4 >= 2 ) {
          ans ++ ;
          M [ 3 ] -= 2 ;
          M [ 2 ] -- ;
        }
      }
      int threes = M [ 3 ] / 4 ;
      int ones = M [ 1 ] / 4 ;
      ans += threes + ones ;
      if ( M [ 1 ] % 4 == 0 && M [ 3 ] % 4 == 0 && M [ 2 ] % 2 == 0 ) {
        ans -- ;
      }
    }
    System . out . printf ( "Case #%d: %d\n" , ii , ans ) ;
  }
}

public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int TT = sc . nextInt ( ) ; for ( int ii = 1 ; ii <= TT ; ++ ii ) { int N = sc . nextInt ( ) ; int P = sc . nextInt ( ) ; int [ ] M = new int [ 5 ] ; for ( int i = 0 ; i < N ; ++ i ) { int G = sc . nextInt ( ) ; M [ G % P ] ++ ; } int ans = 1 + M [ 0 ] ; if ( P == 2 ) { ans += M [ 1 ] / 2 ; if ( M [ 1 ] % 2 == 0 ) ans -- ; } else if ( P == 3 ) { int min = Math . min ( M [ 1 ] , M [ 2 ] ) ; int left = Math . max ( M [ 1 ] , M [ 2 ] ) - min ; if ( left % 3 == 0 ) ans -- ; left /= 3 ; ans += min + left ; } else if ( P == 4 ) { while ( M [ 2 ] >= 2 ) { ans ++ ; M [ 2 ] -= 2 ; } while ( M [ 1 ] > 0 && M [ 3 ] > 0 ) { ans ++ ; M [ 1 ] -- ; M [ 3 ] -- ; } if ( M [ 2 ] == 1 ) { if ( M [ 1 ] % 4 >= 2 ) { ans ++ ; M [ 1 ] -= 2 ; M [ 2 ] -- ; } else if ( M [ 3 ] % 4 >= 2 ) { ans ++ ; M [ 3 ] -= 2 ; M [ 2 ] -- ; } } int threes = M [ 3 ] / 4 ; int ones = M [ 1 ] / 4 ; ans += threes + ones ; if ( M [ 1 ] % 4 == 0 && M [ 3 ] % 4 == 0 && M [ 2 ] % 2 == 0 ) { ans -- ; } } System . out . printf ( " Case ▁ # % d : ▁ % d \n " , ii , ans ) ; } }
(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 (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (identifier) right: (identifier))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (decimal_integer_literal) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)) (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)) (array_access array: (identifier) index: (decimal_integer_literal)))) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (while_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) body: (block (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) body: (block (expression_statement (update_expression (identifier))) (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal)))) (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (expression_statement (update_expression (array_access array: (identifier) index: (decimal_integer_literal))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (decimal_integer_literal))) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (update_expression (identifier))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier) (identifier))))))))