public static void main ( String [ ] args ) {
  Scanner in = new Scanner ( System . in ) ;
  int T = in . nextInt ( ) ;
  for ( int zz = 1 ;
  zz <= T ;
  zz ++ ) {
    int N = in . nextInt ( ) ;
    int [ ] A = new int [ N ] ;
    int [ ] B = new int [ N ] ;
    for ( int i = 0 ;
    i < N ;
    i ++ ) {
      A [ i ] = in . nextInt ( ) ;
      B [ i ] = in . nextInt ( ) ;
    }
    int [ ] have = new int [ N ] ;
    int stars = 0 ;
    int ans = 0 ;
    next : while ( stars < 2 * N ) {
      int best = - 1 ;
      for ( int i = 0 ;
      i < N ;
      i ++ ) {
        if ( have [ i ] == 2 ) continue ;
        if ( stars >= B [ i ] ) {
          stars += 2 - have [ i ] ;
          have [ i ] = 2 ;
          ans ++ ;
          continue next ;
        }
        if ( have [ i ] == 1 ) continue ;
        if ( stars < A [ i ] ) continue ;
        if ( best == - 1 || B [ i ] > B [ best ] ) {
          best = i ;
        }
      }
      if ( best == - 1 ) break ;
      have [ best ] = 1 ;
      ans ++ ;
      stars ++ ;
    }
    if ( stars == 2 * N ) System . out . format ( "Case #%d: %d\n" , zz , ans ) ;
    else System . out . format ( "Case #%d: Too Bad\n" , zz , ans ) ;
  }
}

public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int zz = 1 ; zz <= T ; zz ++ ) { int N = in . nextInt ( ) ; int [ ] A = new int [ N ] ; int [ ] B = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = in . nextInt ( ) ; B [ i ] = in . nextInt ( ) ; } int [ ] have = new int [ N ] ; int stars = 0 ; int ans = 0 ; next : while ( stars < 2 * N ) { int best = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( have [ i ] == 2 ) continue ; if ( stars >= B [ i ] ) { stars += 2 - have [ i ] ; have [ i ] = 2 ; ans ++ ; continue next ; } if ( have [ i ] == 1 ) continue ; if ( stars < A [ i ] ) continue ; if ( best == - 1 || B [ i ] > B [ best ] ) { best = i ; } } if ( best == - 1 ) break ; have [ best ] = 1 ; ans ++ ; stars ++ ; } if ( stars == 2 * N ) System . out . format ( " Case ▁ # % d : ▁ % d \n " , zz , ans ) ; else System . out . format ( " Case ▁ # % d : ▁ Too ▁ Bad \n " , zz , 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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (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 (identifier))))) (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 (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (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 (identifier))))) (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: (decimal_integer_literal))) (labeled_statement (identifier) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (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 (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (array_access array: (identifier) index: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))) (continue_statement (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (break_statement)) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))) (expression_statement (update_expression (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier) (identifier)))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier) (identifier)))))))))