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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education