Guitar Teacher

0

0 votes
Hard
Problem

Himanshu is a very good guitar player and is known for doing covers of different songs on guitar. Watching his extraordinary skills on guitar, Ravi decided that he will also try to learn guitar. But learning guitar is a very difficult thing, so he decided he will take help from Himanshu.

Himanshu, also being one of the best Competitive Programmer of the college, asked Ravi a question to solve and if Ravi is successfull in doing so, himanshu will help him learn guitar.

Himanshu asked the following question. "You are given N binary strings of length M and a final binary string S, you have to calculate how many subset of these N binary string Results to S if we take logical OR of every element in the subset."

For Eg :
let there be 4 binary string of length 2
00, 01, 10, 11
and final string be 11
then possible subsets which satisfy the conditions are

  1. 00, 01, 10, 11 = (00 | 01 | 10 | 11 = 11)
  2. 00, 01, 11 = ( 00 | 01 | 11 = 11)
  3. 00, 10, 11 = ( 00 | 10 | 11 = 11)
  4. 01, 10, 11 = ( 01 | 10 | 11 = 11)
  5. 01, 11 = ( 01 | 11 = 11)
  6. 10, 11 = ( 10 | 11 = 11)
  7. 10, 01, 11 = ( 10 | 01 | 11 = 11)
  8. 11 = ( 11 = 11)
  9. 10, 01 = ( 10 | 01 = 11)
  10. 10, 01, 00 = ( 10 | 01 | 00 = 11)

So total number of subset is 10

Ravi being really weak in programming skills asks for your help.
Help Ravi to solve the task.

Since the answer can be huge , print it modulo 10^9+7

Input
First line contains two space separated number N and M , the number of binary string and length of each binary string.
The next N lines contains the binary string .
Last line contains the final string S

Output
Output in a single line, the number of subsets

Constraints
1<=N<=10^5
1<=M<=20
1 <= length(S) <= 20

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?