public static void main ( String [ ] args ) {
  try ( Scanner sc = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ) {
    int tests = sc . nextInt ( ) ;
    for ( int t = 1 ;
    t <= tests ;
    t ++ ) {
      int [ ] digits = sc . next ( ) . chars ( ) . map ( i -> i - '0' ) . toArray ( ) ;
      for ( int x = 0 ;
      x < digits . length - 1 ;
      x ++ ) {
        if ( digits [ x ] > digits [ x + 1 ] ) {
          digits [ x ] -- ;
          for ( int y = x + 1 ;
          y < digits . length ;
          y ++ ) digits [ y ] = 9 ;
          while ( digits [ x ] < 0 || ( x > 0 && digits [ x ] < digits [ x - 1 ] ) ) {
            digits [ x ] = 9 ;
            digits [ x - 1 ] -- ;
            x -- ;
          }
          break ;
        }
      }
      int start = 0 ;
      while ( digits [ start ] == 0 ) start ++ ;
      StringBuilder sb = new StringBuilder ( ) ;
      for ( int x = start ;
      x < digits . length ;
      x ++ ) sb . append ( ( char ) ( digits [ x ] + '0' ) ) ;
      System . out . printf ( "Case #%d: %s%n" , t , sb . toString ( ) ) ;
    }
  }
}

public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ) { int tests = sc . nextInt ( ) ; for ( int t = 1 ; t <= tests ; t ++ ) { int [ ] digits = sc . next ( ) . chars ( ) . map ( i -> i - '0' ) . toArray ( ) ; for ( int x = 0 ; x < digits . length - 1 ; x ++ ) { if ( digits [ x ] > digits [ x + 1 ] ) { digits [ x ] -- ; for ( int y = x + 1 ; y < digits . length ; y ++ ) digits [ y ] = 9 ; while ( digits [ x ] < 0 || ( x > 0 && digits [ x ] < digits [ x - 1 ] ) ) { digits [ x ] = 9 ; digits [ x - 1 ] -- ; x -- ; } break ; } } int start = 0 ; while ( digits [ start ] == 0 ) start ++ ; StringBuilder sb = new StringBuilder ( ) ; for ( int x = start ; x < digits . length ; x ++ ) sb . append ( ( char ) ( digits [ x ] + '0' ) ) ; System . out . printf ( " Case ▁ # % d : ▁ % s % n " , t , sb . toString ( ) ) ; } } }
(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_with_resources_statement resources: (resource_specification (resource type: (type_identifier) name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))))) body: (block (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (binary_expression left: (identifier) right: (character_literal))))) 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: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (block (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) (expression_statement (update_expression (identifier))))) (break_statement))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) body: (expression_statement (update_expression (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (character_literal)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))))))