public static void main ( String [ ] args ) {
  Scanner in = new Scanner ( System . in ) ;
  int numCases = in . nextInt ( ) ;
  int numRows = in . nextInt ( ) ;
  int setSize = in . nextInt ( ) ;
  int setLimit = in . nextInt ( ) ;
  int numProducts = in . nextInt ( ) ;
  long [ ] products = new long [ numProducts ] ;
  StringBuilder output = new StringBuilder ( ) ;
  for ( int caseNum = 1 ;
  caseNum <= numCases ;
  ++ caseNum ) {
    output . append ( String . format ( "Case #%d:\n" , caseNum ) ) ;
    for ( int curRow = 0 ;
    curRow < numRows ;
    ++ curRow ) {
      for ( int i = 0 ;
      i < numProducts ;
      ++ i ) products [ i ] = in . nextLong ( ) ;
      int [ ] best = new int [ setSize ] ;
      Arrays . fill ( best , 2 ) ;
      double bestProb = 0.0 ;
      for ( int e1 = 2 ;
      e1 <= setLimit ;
      ++ e1 ) {
        for ( int e2 = 2 ;
        e2 <= setLimit ;
        ++ e2 ) {
          for ( int e3 = 2 ;
          e3 <= setLimit ;
          ++ e3 ) {
            int [ ] tempSet = new int [ ] {
              e1 , e2 , e3 };
              double checkProb = 1.0 ;
              for ( int pCheck = 0 ;
              pCheck < products . length ;
              ++ pCheck ) {
                int counter = 0 ;
                for ( int bitMask = 0 ;
                bitMask < ( 1 << tempSet . length ) ;
                ++ bitMask ) {
                  int checkProduct = 1 ;
                  for ( int bit = 1 , idx = 0 ;
                  bit <= bitMask ;
                  bit <<= 1 , ++ idx ) {
                    if ( ( bit & bitMask ) != 0 ) {
                      checkProduct *= tempSet [ idx ] ;
                    }
                  }
                  if ( checkProduct == products [ pCheck ] ) {
                    ++ counter ;
                  }
                }
                checkProb *= ( counter / 8.0 ) ;
              }
              if ( checkProb > bestProb ) {
                best = tempSet ;
                bestProb = checkProb ;
              }
            }
          }
        }
        output . append ( best [ 0 ] ) ;
        output . append ( best [ 1 ] ) ;
        output . append ( best [ 2 ] ) ;
        output . append ( '\n' ) ;
      }
    }
    System . out . print ( output ) ;
  }
  
public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int numCases = in . nextInt ( ) ; int numRows = in . nextInt ( ) ; int setSize = in . nextInt ( ) ; int setLimit = in . nextInt ( ) ; int numProducts = in . nextInt ( ) ; long [ ] products = new long [ numProducts ] ; StringBuilder output = new StringBuilder ( ) ; for ( int caseNum = 1 ; caseNum <= numCases ; ++ caseNum ) { output . append ( String . format ( " Case ▁ # % d : \n " , caseNum ) ) ; for ( int curRow = 0 ; curRow < numRows ; ++ curRow ) { for ( int i = 0 ; i < numProducts ; ++ i ) products [ i ] = in . nextLong ( ) ; int [ ] best = new int [ setSize ] ; Arrays . fill ( best , 2 ) ; double bestProb = 0.0 ; for ( int e1 = 2 ; e1 <= setLimit ; ++ e1 ) { for ( int e2 = 2 ; e2 <= setLimit ; ++ e2 ) { for ( int e3 = 2 ; e3 <= setLimit ; ++ e3 ) { int [ ] tempSet = new int [ ] { e1 , e2 , e3 } ; double checkProb = 1.0 ; for ( int pCheck = 0 ; pCheck < products . length ; ++ pCheck ) { int counter = 0 ; for ( int bitMask = 0 ; bitMask < ( 1 << tempSet . length ) ; ++ bitMask ) { int checkProduct = 1 ; for ( int bit = 1 , idx = 0 ; bit <= bitMask ; bit <<= 1 , ++ idx ) { if ( ( bit & bitMask ) != 0 ) { checkProduct *= tempSet [ idx ] ; } } if ( checkProduct == products [ pCheck ] ) { ++ counter ; } } checkProb *= ( counter / 8.0 ) ; } if ( checkProb > bestProb ) { best = tempSet ; bestProb = checkProb ; } } } } output . append ( best [ 0 ] ) ; output . append ( best [ 1 ] ) ; output . append ( best [ 2 ] ) ; output . append ( ' \n ' ) ; } } System . out . print ( output ) ; }
(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)))) (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: (integral_type) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (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: (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: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (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 (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: (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (decimal_floating_point_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 (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 (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: (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (identifier) (identifier) (identifier))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (decimal_floating_point_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: (field_access object: (identifier) field: (identifier))) 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: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (field_access object: (identifier) field: (identifier))))) 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)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (update_expression (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_floating_point_literal))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (character_literal)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))