public static void main ( String args [ ] ) throws FileNotFoundException {
  Scanner s = new Scanner ( new FileInputStream ( "A-large.in" ) ) ;
  int cnt = s . nextInt ( ) ;
  for ( int cases = 0 ;
  cases < cnt ;
  cases ++ ) {
    String buf = s . next ( ) ;
    long num = 0 ;
    int bb = - 1 ;
    int [ ] ar = new int [ buf . length ( ) ] ;
    HashMap < String , Integer > set = new HashMap < String , Integer > ( ) ;
    set . put ( buf . substring ( 0 , 1 ) , 1 ) ;
    for ( int i = 0 ;
    i < buf . length ( ) ;
    i ++ ) {
      if ( set . containsKey ( buf . substring ( i , i + 1 ) ) ) {
        ar [ i ] = set . get ( buf . substring ( i , i + 1 ) ) ;
      }
      else {
        bb ++ ;
        if ( bb == 1 ) {
          bb = 2 ;
        }
        set . put ( buf . substring ( i , i + 1 ) , bb ) ;
        ar [ i ] = bb ;
      }
    }
    bb ++ ;
    if ( bb < 2 ) {
      bb = 2 ;
    }
    for ( int i = 0 ;
    i < buf . length ( ) ;
    i ++ ) {
      long temp = 1 ;
      for ( int j = 0 ;
      j < buf . length ( ) - i - 1 ;
      j ++ ) {
        temp = temp * ( long ) bb ;
      }
      num += ( long ) ar [ i ] * temp ;
    }
    System . out . println ( "Case #" + ( cases + 1 ) + ": " + num ) ;
  }
}

public static void main ( String args [ ] ) throws FileNotFoundException { Scanner s = new Scanner ( new FileInputStream ( " A - large . in " ) ) ; int cnt = s . nextInt ( ) ; for ( int cases = 0 ; cases < cnt ; cases ++ ) { String buf = s . next ( ) ; long num = 0 ; int bb = - 1 ; int [ ] ar = new int [ buf . length ( ) ] ; HashMap < String , Integer > set = new HashMap < String , Integer > ( ) ; set . put ( buf . substring ( 0 , 1 ) , 1 ) ; for ( int i = 0 ; i < buf . length ( ) ; i ++ ) { if ( set . containsKey ( buf . substring ( i , i + 1 ) ) ) { ar [ i ] = set . get ( buf . substring ( i , i + 1 ) ) ; } else { bb ++ ; if ( bb == 1 ) { bb = 2 ; } set . put ( buf . substring ( i , i + 1 ) , bb ) ; ar [ i ] = bb ; } } bb ++ ; if ( bb < 2 ) { bb = 2 ; } for ( int i = 0 ; i < buf . length ( ) ; i ++ ) { long temp = 1 ; for ( int j = 0 ; j < buf . length ( ) - i - 1 ; j ++ ) { temp = temp * ( long ) bb ; } num += ( long ) ar [ i ] * temp ; } System . out . println ( " Case ▁ # " + ( cases + 1 ) + " : ▁ " + num ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) (throws (type_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 (string_literal))))))) (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: (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) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))) (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal))))))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) alternative: (block (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))) (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))))) (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (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: (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (identifier)) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (cast_expression type: (integral_type) value: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (cast_expression type: (integral_type) value: (array_access array: (identifier) index: (identifier))) right: (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (string_literal)) right: (identifier)))))))))