This page is still under construction.

Parts of this page are still being built. What you see may change.

How many binary sequences

Time limit3sMemory limit256 MB

Summary
Find the smallest set of length-K binary strings so each given 0-1-2 string with at most two ones is the sum of two members at Hamming distance at most two.
Level

Medium7 of 10

Topics
Brute force, Bit manipulation
Solved
No attempts yet

Problem

You are given a set BB of binary sequences of length KK. Every element of BB is a sequence of KK values, each of them 00 or 11.

An integer sequence ZiZ_i is built by this process.

  1. Pick a sequence X=(x1,x2,…,xK)X = (x_1, x_2, \dots, x_K) from BB.
  2. Pick a sequence Y=(y1,y2,…,yK)Y = (y_1, y_2, \dots, y_K) from BB with dist(X,Y)≤2\mathrm{dist}(X, Y) \le 2. Here dist(X,Y)\mathrm{dist}(X, Y) is the Hamming distance of the two sequences, the number of positions where the two values differ. For example, dist((1,0,1,1),(1,1,1,1))=1\mathrm{dist}((1,0,1,1), (1,1,1,1)) = 1 and dist((1,0,1,1,1,0,1),(1,0,0,1,0,0,1))=2\mathrm{dist}((1,0,1,1,1,0,1), (1,0,0,1,0,0,1)) = 2. You may pick the same element as both XX and YY.
  3. Set Zi=(x1+y1,x2+y2,…,xK+yK)Z_i = (x_1 + y_1, x_2 + y_2, \dots, x_K + y_K).

For example, Zi=(1,0,1,2,2)Z_i = (1,0,1,2,2) can be built from X=(1,0,0,1,1)X = (1,0,0,1,1) and Y=(0,0,1,1,1)Y = (0,0,1,1,1).

You are given NN integer sequences Z1,Z2,…,ZNZ_1, Z_2, \dots, Z_N built this way. Among all sets BB that can build all NN of them, find one with the fewest elements and print how many elements it has.

Input

The first line contains KK and NN, separated by one space. (1≤K≤201 \le K \le 20, 1≤N≤241 \le N \le 24)

Each of the next NN lines contains one sequence ZiZ_i. The jj-th character of the ii-th line is the value of Zi,jZ_{i,j}, and there is no separator between characters. Each value is 00, 11, or 22, and each line contains at most two 11s, so every given ZiZ_i can be built by the process above.

Output

Print the minimum number of elements of the set BB.

Examples1

  1. Example 1

    Input
    5 2
    10122
    20022
    
    Expected output
    2