understands that Omkar's timberland is a n by m lattice (1≤n,m≤2000) of some non-negative integers. Since the backwoods is honored by Omkar, it fulfills some exceptional conditions: For any two nearby (sharing a side) cells, the outright worth of the distinction of numbers in them is all things considered 1.
Python language only. Correct answer will upvoted else downvoted.
Ajit understands that Omkar's timberland is a n by m lattice (1≤n,m≤2000) of some non-negative integers. Since the backwoods is honored by Omkar, it fulfills some exceptional conditions:
For any two nearby (sharing a side) cells, the outright worth of the distinction of numbers in them is all things considered 1.
On the off chance that the number in some cell is completely bigger than 0, it ought to be totally more prominent than the number in something like one of the cells contiguous it.
Shockingly, Ajit isn't completely deserving of Omkar's forces yet. He considers each to be as a "0" or a "#". Assuming a cell is named as "0", the number in it should approach 0. Any other way, the number in it very well may be any nonnegative integer.
Decide the number of various tasks of components exist to such an extent that these extraordinary conditions are fulfilled. Two tasks are considered unique if there exists something like one cell with the end goal that the numbers written in it in these tasks are unique. Since the appropriate response might be tremendous, discover the appropriate response modulo 109+7.
Input
Each test contains numerous experiments. The primary line contains the number of experiments t (1≤t≤100). Portrayal of the experiments follows.
The primary line of each experiment contains two integers n and m (1≤n,m≤2000,nm≥2) – the components of the backwoods.
n lines follow, each comprising of one line of m characters. Every one of these characters is either a "0" or a "#".
It is ensured that the amount of n over all experiments doesn't surpass 2000 and the amount of m over all experiments doesn't surpass 2000.
Output
For each experiment, print one integer: the number of legitimate arrangements modulo 109+7.
Step by step
Solved in 3 steps with 1 images