Task
This is the legend of the old, long-lost package in Dristor 2.
A long time ago, AAP, MH, MFast and the other package hunters were tasked with finding a lost package in the Dristor 2 station. It is known that there are package hunters and secret locations in the Dristor 2 station. For each of the package hunters, the secret locations he knows how to reach are known. Since none of them know the station well enough, they decided to split up to increase their chances of finding the package.
In one search, every package hunter must check at most one secret location he knows how to reach and no two hunters should check the same secret location. In each search, the number of package hunters that are not checking any of the secret locations is minimized (i.e. the number of secret locations that are checked is maximized). You should count the number of different searches the group can try in order to find the lost package. Since this number can be very large, you should print it modulo . Two searches are considered different if at least one package hunter checks a different locations in the two searches.
Input
The first line of the input will contain and . The next lines of the input will each contain binary values. If the value on the line is , then the package hunter knows how to reach the location. If the value is , then the package hunter does not know how to reach the location.
Output
You should output the number of different searches the group can try (modulo ).
Restrictions
- For tests worth points, .
- For tests worth more points, each of the package hunters knows where all the secret locations are.
Example
stdin
4 4
0 1 1 0
1 1 0 1
1 0 0 0
0 1 1 1
stdout
3