Hiring Chefs

All submissions for this problem are available.
### Read problems statements in [Hindi](http://www.codechef.com/download/translated/COOK110/hindi/HIRING.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/COOK110/mandarin/HIRING.pdf), [Russian](http://www.codechef.com/download/translated/COOK110/russian/HIRING.pdf), [Vietnamese](http://www.codechef.com/download/translated/COOK110/vietnamese/HIRING.pdf), and [Bengali](http://www.codechef.com/download/translated/COOK110/bengali/HIRING.pdf) as well. Chef Shahhoud wants to hire new chefs for his restaurant. Shahhoud posted a job offer on Chef Rami's paper "Fast Food Times". $N$ candidates (numbered $1$ through $N$) have applied for the job. There are $M$ traits that define how good a chef is. You are given $N$ strings $S_1, S_2, \ldots, S_N$ describing the traits of the candidates. Each of these strings has length $M$. For each valid $i$ and $j$, the $j$th character of $S_i$ is '1' if the $i$th chef has the $j$th trait or '0' if this chef does not have this trait. Shahhoud wants to choose a nonempty subsequence $H$ (not necessarily contiguous) of the sequence $(1, 2, \ldots, N)$ and hire all candidates from $H$. However, the sequence $H$ must satisfy an additional condition: for any two consecutive elements of $H$ (let's denote them by $x$ and $y$), candidates $x$ and $y$ have no common traits, to prevent fights between them. Now, Shahhoud is wondering: how many such valid subsequences exist? Find this number modulo $1,000,000,007$ ($10^9 + 7$). ### Input  The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.  The first line of each test case contains two spaceseparated integers $N$ and $M$.  $N$ lines follow. For each $i$ ($1 \le i \le N$), the $i$th of these lines contains a single string $S_i$. ### Output For each test case, print a single line containing one integer — the number of valid subsequences modulo $1,000,000,007$. ### Constraints  $1 \le T \le 100$  $1 \le M \le 16$  $1 \le N \le 100,000$  $S_i = M$ for each valid $i$  $S_1, S_2, \ldots, S_M$ contain only characters '0' and '1'  the sum of $N$ over all test cases does not exceed $500,000$ ### Example Input ``` 1 4 2 10 01 11 10 ``` ### Example Output ``` 7 ``` ### Explanation **Example case 1:** The valid subsequences are $(1)$, $(2)$, $(3)$, $(4)$, $(1,2)$, $(2,4)$ and $(1,2,4)$.Author:  joudzouzou 
Editorial  https://discuss.codechef.com/problems/HIRING 
Tags  cook110, dynamicprogramming, easymedium, joudzouzou, meetinmiddle, taran_1407 
Date Added:  21092019 
Time Limit:  5 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 