public static void main ( String [ ] args ) {
  int n = scanner . nextInt ( ) ;
  int [ ] [ ] f = IntStream . range ( 0 , n ) . mapToObj ( i -> IntStream . range ( 0 , 10 ) . map ( j -> scanner . nextInt ( ) ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ;
  int [ ] [ ] p = IntStream . range ( 0 , n ) . mapToObj ( i -> IntStream . range ( 0 , 11 ) . map ( j -> scanner . nextInt ( ) ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ;
  IntStream . range ( 1 , 1024 ) . map ( i -> IntStream . range ( 0 , n ) . map ( j -> p [ j ] [ ( int ) IntStream . range ( 0 , 10 ) . filter ( k -> ( i >> k & 1 ) == 1 && f [ j ] [ k ] == 1 ) . count ( ) ] ) . sum ( ) ) . max ( ) . ifPresent ( System . out :: println ) ;
}

public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) ; int [ ] [ ] f = IntStream . range ( 0 , n ) . mapToObj ( i -> IntStream . range ( 0 , 10 ) . map ( j -> scanner . nextInt ( ) ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ; int [ ] [ ] p = IntStream . range ( 0 , n ) . mapToObj ( i -> IntStream . range ( 0 , 11 ) . map ( j -> scanner . nextInt ( ) ) . toArray ( ) ) . toArray ( int [ ] [ ] :: new ) ; IntStream . range ( 1 , 1024 ) . map ( i -> IntStream . range ( 0 , n ) . map ( j -> p [ j ] [ ( int ) IntStream . range ( 0 , 10 ) . filter ( k -> ( i >> k & 1 ) == 1 && f [ j ] [ k ] == 1 ) . count ( ) ] ) . sum ( ) ) . max ( ) . ifPresent ( 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: (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: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) name: (identifier) arguments: (argument_list))))) name: (identifier) arguments: (argument_list (method_reference (array_type element: (integral_type) dimensions: (dimensions))))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) name: (identifier) arguments: (argument_list))))) name: (identifier) arguments: (argument_list (method_reference (array_type element: (integral_type) dimensions: (dimensions))))))) (expression_statement (method_invocation object: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (array_access array: (array_access array: (identifier) index: (identifier)) index: (cast_expression type: (integral_type) value: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (decimal_integer_literal)))))) name: (identifier) arguments: (argument_list))))))) name: (identifier) arguments: (argument_list))))) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (method_reference (field_access object: (identifier) field: (identifier)) (identifier)))))))