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 C = sc . nextInt ( ) ;
    int M = sc . nextInt ( ) ;
    int [ ] COUNT = new int [ C + 1 ] ;
    int [ ] coast = new int [ N + 1 ] ;
    for ( int i = 0 ;
    i < M ;
    ++ i ) {
      int pos = sc . nextInt ( ) ;
      int buyer = sc . nextInt ( ) ;
      COUNT [ buyer ] ++ ;
      coast [ pos ] ++ ;
    }
    int min = 0 ;
    for ( int i = 0 ;
    i < COUNT . length ;
    ++ i ) {
      if ( COUNT [ i ] > min ) min = COUNT [ i ] ;
    }
    min = Math . max ( min , coast [ 1 ] ) ;
    int max = M ;
    while ( min < max ) {
      int piv = ( min + max ) / 2 ;
      int promotions = canDo ( coast , piv ) ;
      if ( promotions >= 0 ) {
        if ( max == piv ) System . err . println ( "whoops" ) ;
        max = piv ;
      }
      else {
        min = piv + 1 ;
      }
    }
    if ( min != max ) System . err . println ( "never" ) ;
    int ans = canDo ( coast , max ) ;
    System . out . printf ( "Case #%d: %d %d\n" , ii , max , 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 C = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] COUNT = new int [ C + 1 ] ; int [ ] coast = new int [ N + 1 ] ; for ( int i = 0 ; i < M ; ++ i ) { int pos = sc . nextInt ( ) ; int buyer = sc . nextInt ( ) ; COUNT [ buyer ] ++ ; coast [ pos ] ++ ; } int min = 0 ; for ( int i = 0 ; i < COUNT . length ; ++ i ) { if ( COUNT [ i ] > min ) min = COUNT [ i ] ; } min = Math . max ( min , coast [ 1 ] ) ; int max = M ; while ( min < max ) { int piv = ( min + max ) / 2 ; int promotions = canDo ( coast , piv ) ; if ( promotions >= 0 ) { if ( max == piv ) System . err . println ( " whoops " ) ; max = piv ; } else { min = piv + 1 ; } } if ( min != max ) System . err . println ( " never " ) ; int ans = canDo ( coast , max ) ; System . out . printf ( " Case ▁ # % d : ▁ % d ▁ % d \n " , ii , max , 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: (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 (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (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 (binary_expression left: (identifier) right: (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)))) (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: (identifier)))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))) (expression_statement (assignment_expression left: (identifier) right: (identifier)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier) (identifier) (identifier))))))))