public static void main ( String [ ] args ) throws Exception {
  int i , j , k , p ;
  char c ;
  int res ;
  String score ;
  String line ;
  String sentence ;
  String original = "welcome to code jam" ;
  int N , M ;
  BufferedReader br = new BufferedReader ( new FileReader ( "C-large.in" ) ) ;
  PrintWriter out = new PrintWriter ( new BufferedWriter ( new FileWriter ( "C-large.out" ) ) ) ;
  StringTokenizer st ;
  line = br . readLine ( ) ;
  N = Integer . parseInt ( line ) ;
  for ( k = 1 ;
  k <= N ;
  k ++ ) {
    sentence = br . readLine ( ) ;
    M = sentence . length ( ) ;
    int opt [ ] [ ] = new int [ M ] [ 19 ] ;
    for ( i = 0 ;
    i < M ;
    i ++ ) {
      c = sentence . charAt ( i ) ;
      if ( c == 'w' ) {
        opt [ i ] [ 0 ] = 1 ;
      }
      for ( j = 1 ;
      j < 19 ;
      j ++ ) {
        if ( c == original . charAt ( j ) ) {
          for ( p = 0 ;
          p < i ;
          p ++ ) {
            opt [ i ] [ j ] = ( opt [ i ] [ j ] + opt [ p ] [ j - 1 ] ) % 10000 ;
          }
        }
      }
    }
    res = 0 ;
    for ( i = 0 ;
    i < M ;
    i ++ ) {
      res = ( res + opt [ i ] [ 18 ] ) % 10000 ;
    }
    score = Integer . toString ( res ) ;
    while ( score . length ( ) < 4 ) {
      score = '0' + score ;
    }
    out . println ( "Case #" + k + ": " + score ) ;
  }
  out . close ( ) ;
  System . exit ( 0 ) ;
}

public static void main ( String [ ] args ) throws Exception { int i , j , k , p ; char c ; int res ; String score ; String line ; String sentence ; String original = " welcome ▁ to ▁ code ▁ jam " ; int N , M ; BufferedReader br = new BufferedReader ( new FileReader ( " C - large . in " ) ) ; PrintWriter out = new PrintWriter ( new BufferedWriter ( new FileWriter ( " C - large . out " ) ) ) ; StringTokenizer st ; line = br . readLine ( ) ; N = Integer . parseInt ( line ) ; for ( k = 1 ; k <= N ; k ++ ) { sentence = br . readLine ( ) ; M = sentence . length ( ) ; int opt [ ] [ ] = new int [ M ] [ 19 ] ; for ( i = 0 ; i < M ; i ++ ) { c = sentence . charAt ( i ) ; if ( c == ' w ' ) { opt [ i ] [ 0 ] = 1 ; } for ( j = 1 ; j < 19 ; j ++ ) { if ( c == original . charAt ( j ) ) { for ( p = 0 ; p < i ; p ++ ) { opt [ i ] [ j ] = ( opt [ i ] [ j ] + opt [ p ] [ j - 1 ] ) % 10000 ; } } } } res = 0 ; for ( i = 0 ; i < M ; i ++ ) { res = ( res + opt [ i ] [ 18 ] ) % 10000 ; } score = Integer . toString ( res ) ; while ( score . length ( ) < 4 ) { score = '0' + score ; } out . println ( " Case ▁ # " + k + " : ▁ " + score ) ; } out . close ( ) ; System . exit ( 0 ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) 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 (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))))) (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 (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (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 (identifier)) dimensions: (dimensions_expr (decimal_integer_literal))))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (decimal_integer_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: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (decimal_integer_literal)))))))))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (while_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (character_literal) right: (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal)) right: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))))))