public static void main ( String [ ] args ) {
  BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
  try {
    int cases = Integer . valueOf ( input . readLine ( ) ) ;
    for ( int cas = 1 ;
    cas <= cases ;
    cas ++ ) {
      String line = input . readLine ( ) ;
      int digit [ ] = new int [ 256 ] ;
      int base = 0 , i ;
      BigInteger num = new BigInteger ( "0" ) ;
      for ( i = 0 ;
      i < 256 ;
      i ++ ) digit [ i ] = - 1 ;
      for ( i = 0 ;
      i < line . length ( ) ;
      i ++ ) {
        if ( ( line . charAt ( i ) < '0' || line . charAt ( i ) > '9' ) && ( line . charAt ( i ) < 'a' || line . charAt ( i ) > 'z' ) ) continue ;
        if ( digit [ line . charAt ( i ) ] == - 1 ) {
          if ( base == 0 ) digit [ line . charAt ( i ) ] = 1 ;
          else if ( base == 1 ) digit [ line . charAt ( i ) ] = 0 ;
          else digit [ line . charAt ( i ) ] = base ;
          base ++ ;
        }
      }
      if ( base < 2 ) base = 2 ;
      int cnt = 0 ;
      for ( i = 0 ;
      i < line . length ( ) ;
      i ++ ) {
        if ( ( line . charAt ( i ) < '0' || line . charAt ( i ) > '9' ) && ( line . charAt ( i ) < 'a' || line . charAt ( i ) > 'z' ) ) continue ;
        num = num . multiply ( BigInteger . valueOf ( base ) ) ;
        num = num . add ( BigInteger . valueOf ( digit [ line . charAt ( i ) ] ) ) ;
      }
      System . out . printf ( "Case #%d: " , cas ) ;
      System . out . println ( num ) ;
    }
  }
  catch ( java . io . IOException e ) {
  }
}

public static void main ( String [ ] args ) { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { int cases = Integer . valueOf ( input . readLine ( ) ) ; for ( int cas = 1 ; cas <= cases ; cas ++ ) { String line = input . readLine ( ) ; int digit [ ] = new int [ 256 ] ; int base = 0 , i ; BigInteger num = new BigInteger ( "0" ) ; for ( i = 0 ; i < 256 ; i ++ ) digit [ i ] = - 1 ; for ( i = 0 ; i < line . length ( ) ; i ++ ) { if ( ( line . charAt ( i ) < '0' || line . charAt ( i ) > '9' ) && ( line . charAt ( i ) < ' a ' || line . charAt ( i ) > ' z ' ) ) continue ; if ( digit [ line . charAt ( i ) ] == - 1 ) { if ( base == 0 ) digit [ line . charAt ( i ) ] = 1 ; else if ( base == 1 ) digit [ line . charAt ( i ) ] = 0 ; else digit [ line . charAt ( i ) ] = base ; base ++ ; } } if ( base < 2 ) base = 2 ; int cnt = 0 ; for ( i = 0 ; i < line . length ( ) ; i ++ ) { if ( ( line . charAt ( i ) < '0' || line . charAt ( i ) > '9' ) && ( line . charAt ( i ) < ' a ' || line . charAt ( i ) > ' z ' ) ) continue ; num = num . multiply ( BigInteger . valueOf ( base ) ) ; num = num . add ( BigInteger . valueOf ( digit [ line . charAt ( i ) ] ) ) ; } System . out . printf ( " Case ▁ # % d : ▁ " , cas ) ; System . out . println ( num ) ; } } catch ( java . io . IOException e ) { } }
(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 (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (try_statement body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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: (type_identifier) 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) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal))))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) right: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (decimal_integer_literal))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (decimal_integer_literal))) alternative: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (identifier))))) (expression_statement (update_expression (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) right: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))))) consequence: (continue_statement)) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))) (catch_clause (catch_formal_parameter (catch_type (scoped_type_identifier (scoped_type_identifier (type_identifier) (type_identifier)) (type_identifier))) name: (identifier)) body: (block)))))