public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int numCases = sc . nextInt ( ) ;
  for ( int caseNum = 1 ;
  caseNum <= numCases ;
  caseNum ++ ) {
    int P = sc . nextInt ( ) ;
    int [ ] E = new int [ P ] ;
    int [ ] F = new int [ P ] ;
    for ( int i = 0 ;
    i < P ;
    i ++ ) {
      E [ i ] = sc . nextInt ( ) ;
    }
    int total = 0 ;
    for ( int i = 0 ;
    i < P ;
    i ++ ) {
      F [ i ] = sc . nextInt ( ) ;
      total += F [ i ] ;
    }
    int numElems = ( int ) ( Math . log ( total ) / Math . log ( 2 ) + 0.5 ) ;
    List < Integer > S = new ArrayList < > ( ) ;
    Map < Integer , Integer > frequencies = new HashMap < > ( ) ;
    frequencies . put ( 0 , 1 ) ;
    for ( int i = 0 ;
    i < P ;
    i ++ ) {
      if ( ! frequencies . containsKey ( E [ i ] ) ) {
        frequencies . put ( E [ i ] , 0 ) ;
      }
      while ( frequencies . get ( E [ i ] ) < F [ i ] ) {
        S . add ( E [ i ] ) ;
        Map < Integer , Integer > temp = new HashMap < > ( frequencies ) ;
        for ( Map . Entry < Integer , Integer > entry : frequencies . entrySet ( ) ) {
          int sum = entry . getKey ( ) + E [ i ] ;
          if ( temp . containsKey ( sum ) ) {
            temp . put ( sum , entry . getValue ( ) + frequencies . get ( sum ) ) ;
          }
          else {
            temp . put ( sum , entry . getValue ( ) ) ;
          }
        }
        frequencies = temp ;
      }
    }
    System . out . print ( "Case #" + caseNum + ":" ) ;
    for ( int i : S ) {
      System . out . print ( " " + i ) ;
    }
    System . out . println ( ) ;
  }
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int numCases = sc . nextInt ( ) ; for ( int caseNum = 1 ; caseNum <= numCases ; caseNum ++ ) { int P = sc . nextInt ( ) ; int [ ] E = new int [ P ] ; int [ ] F = new int [ P ] ; for ( int i = 0 ; i < P ; i ++ ) { E [ i ] = sc . nextInt ( ) ; } int total = 0 ; for ( int i = 0 ; i < P ; i ++ ) { F [ i ] = sc . nextInt ( ) ; total += F [ i ] ; } int numElems = ( int ) ( Math . log ( total ) / Math . log ( 2 ) + 0.5 ) ; List < Integer > S = new ArrayList < > ( ) ; Map < Integer , Integer > frequencies = new HashMap < > ( ) ; frequencies . put ( 0 , 1 ) ; for ( int i = 0 ; i < P ; i ++ ) { if ( ! frequencies . containsKey ( E [ i ] ) ) { frequencies . put ( E [ i ] , 0 ) ; } while ( frequencies . get ( E [ i ] ) < F [ i ] ) { S . add ( E [ i ] ) ; Map < Integer , Integer > temp = new HashMap < > ( frequencies ) ; for ( Map . Entry < Integer , Integer > entry : frequencies . entrySet ( ) ) { int sum = entry . getKey ( ) + E [ i ] ; if ( temp . containsKey ( sum ) ) { temp . put ( sum , entry . getValue ( ) + frequencies . get ( sum ) ) ; } else { temp . put ( sum , entry . getValue ( ) ) ; } } frequencies = temp ; } } System . out . print ( " Case ▁ # " + caseNum + " : " ) ; for ( int i : S ) { System . out . print ( " ▁ " + i ) ; } System . out . println ( ) ; } }
(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)))))) (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: (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: (identifier) right: (array_access array: (identifier) index: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) right: (decimal_floating_point_literal)))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) 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)) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (decimal_integer_literal)))))) (while_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))) right: (array_access array: (identifier) index: (identifier)))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))) (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)) arguments: (argument_list (identifier))))) (enhanced_for_statement type: (generic_type (scoped_type_identifier (type_identifier) (type_identifier)) (type_arguments (type_identifier) (type_identifier))) name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (array_access array: (identifier) index: (identifier))))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) alternative: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))))) (expression_statement (assignment_expression left: (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: (string_literal) right: (identifier)) right: (string_literal))))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list)))))))