public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int cases = sc . nextInt ( ) ;
  for ( int caze = 1 ;
  caze <= cases ;
  caze ++ ) {
    int N = sc . nextInt ( ) ;
    int L = sc . nextInt ( ) ;
    Set < Long > need = new HashSet < Long > ( ) , have = new HashSet < Long > ( ) ;
    for ( int i = 0 ;
    i < N ;
    i ++ ) {
      String tmp = sc . next ( ) ;
      long tmp2 = 0 ;
      for ( int j = 0 ;
      j < L ;
      j ++ ) if ( tmp . charAt ( j ) == '1' ) tmp2 |= ( 1L << j ) ;
      have . add ( tmp2 ) ;
    }
    long lastNeeded = 0 ;
    for ( int i = 0 ;
    i < N ;
    i ++ ) {
      String tmp = sc . next ( ) ;
      long tmp2 = 0 ;
      for ( int j = 0 ;
      j < L ;
      j ++ ) if ( tmp . charAt ( j ) == '1' ) tmp2 |= ( 1L << j ) ;
      need . add ( tmp2 ) ;
      lastNeeded = tmp2 ;
    }
    int ans = L + 1 ;
    for ( Long elem : have ) {
      long flip = lastNeeded ^ elem ;
      Set < Long > got = new HashSet < Long > ( ) ;
      for ( Long e : need ) {
        got . add ( e ^ flip ) ;
      }
      if ( got . equals ( have ) ) {
        ans = Math . min ( ans , Long . bitCount ( flip ) ) ;
      }
    }
    System . out . println ( "Case #" + caze + ": " + ( ans > L ? "NOT POSSIBLE" : ans ) ) ;
  }
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cases = sc . nextInt ( ) ; for ( int caze = 1 ; caze <= cases ; caze ++ ) { int N = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; Set < Long > need = new HashSet < Long > ( ) , have = new HashSet < Long > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { String tmp = sc . next ( ) ; long tmp2 = 0 ; for ( int j = 0 ; j < L ; j ++ ) if ( tmp . charAt ( j ) == '1' ) tmp2 |= ( 1L << j ) ; have . add ( tmp2 ) ; } long lastNeeded = 0 ; for ( int i = 0 ; i < N ; i ++ ) { String tmp = sc . next ( ) ; long tmp2 = 0 ; for ( int j = 0 ; j < L ; j ++ ) if ( tmp . charAt ( j ) == '1' ) tmp2 |= ( 1L << j ) ; need . add ( tmp2 ) ; lastNeeded = tmp2 ; } int ans = L + 1 ; for ( Long elem : have ) { long flip = lastNeeded ^ elem ; Set < Long > got = new HashSet < Long > ( ) ; for ( Long e : need ) { got . add ( e ^ flip ) ; } if ( got . equals ( have ) ) { ans = Math . min ( ans , Long . bitCount ( flip ) ) ; } } System . out . println ( " Case ▁ # " + caze + " : ▁ " + ( ans > L ? " NOT ▁ POSSIBLE " : ans ) ) ; } }
(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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (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 (type_identifier))) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (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 (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))) (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: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (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 (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))) (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: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (identifier) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (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 (type_identifier))) arguments: (argument_list)))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (identifier) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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: (identifier)) right: (string_literal)) right: (parenthesized_expression (ternary_expression condition: (binary_expression left: (identifier) right: (identifier)) consequence: (string_literal) alternative: (identifier)))))))))))