output_description: For each dataset, minimize the maximum number of questions by which every
  object is identifiable and output the result.
input_description: The input is a sequence of multiple datasets. Each dataset begins with a line
  which consists of two integers, _m_ and _n_ : the number of features, and the
  number of objects, respectively. You can assume 0 < _m_ ≤ 11 and 0 < _n_ ≤
  128\. It is followed by _n_ lines, each of which corresponds to an object.
  Each line includes a binary string of length _m_ which represent the value
  ("yes" or "no") of features. There are no two identical objects.
  
  The end of the input is indicated by a line containing two zeros. There are at
  most 100 datasets.
attempt: from collections import Counter
  
  while True:
      m, n = (int(s) for s in input().split())
      if not m:
          break
  
      objs = [int(input(), 2) for i in range(n)]
      f = [[0 for i in range(1 << m)] for i in range(1 << m)]
  
      for mask in reversed(range(1 << m)):
          s = Counter(obj & mask for obj in objs)
          for mask0 in range(mask + 1):
              if s[mask0] > 1:
                  f[mask][mask0] = n + 1
                  for b in [1 << k for k in range(m)]:
                      if not (b & mask):
                          f[mask][mask0] = min(
                              f[mask][mask0],
                              max(f[mask + b][mask0], f[mask + b][mask0 + b]) + 1,
                          )
      print(f[0][0])
  
problem_description: H: Twenty Questions
  
  Consider a closed world and a set of features that are defined for all the
  objects in the world. Each feature can be answered with "yes" or "no". Using
  those features, we can identify any object from the rest of the objects in the
  world. In other words, each object can be represented as a fixed-length
  sequence of booleans. Any object is different from other objects by at least
  one feature.
  
  You would like to identify an object from others. For this purpose, you can
  ask a series of questions to someone who knows what the object is. Every
  question you can ask is about one of the features. He/she immediately answers
  each question with "yes" or "no" correctly. You can choose the next question
  after you get the answer to the previous question.
  
  You kindly pay the answerer 100 yen as a tip for each question. Because you
  don' t have surplus money, it is necessary to minimize the number of questions
  in the worst case. You don’t know what is the correct answer, but fortunately
  know all the objects in the world. Therefore, you can plan an optimal strategy
  before you start questioning.
  
  The problem you have to solve is: given a set of boolean-encoded objects,
  minimize the maximum number of questions by which every object in the set is
  identifiable.
samples: [{"input": "1\n    11010101\n    11 4\n    00111001100\n    01001101011\n    01010000011\n    01100110001\n    11 16\n    01000101111\n    01011000000\n    01011111001\n    01101101001\n    01110010111\n    01110100111\n    10000001010\n    10010001000\n    10010110100\n    10100010100\n    10101010110\n    10110100010\n    11001010011\n    11011001001\n    11111000111\n    11111011101\n    11 12\n    10000000000\n    01000000000\n    00100000000\n    00010000000\n    00001000000\n    00000100000\n    00000010000\n    00000001000\n    00000000100\n    00000000010\n    00000000001\n    00000000000\n    9 32\n    001000000\n    000100000\n    000010000\n    000001000\n    000000100\n    000000010\n    000000001\n    000000000\n    011000000\n    010100000\n    010010000\n    010001000\n    010000100\n    010000010\n    010000001\n    010000000\n    101000000\n    100100000\n    100010000\n    100001000\n    100000100\n    100000010\n    100000001\n    100000000\n    111000000\n    110100000\n    110010000\n    110001000\n    110000100\n    110000010\n    110000001\n    110000000\n    0 0", "output": "2\n    4\n    11\n    9"}]