You are given a grid of size \(n*m\) containing only 0s and 1s. A cross is a 'X' like structure formed in the grid when any two sequence of diagonal 1s intersects each other. Find the count of total number of crosses present in the grid. Since the answer can be large, compute it modulo \(10^9+7\).
INPUT FORMAT
The first line contains an integer, \(t\) - denoting the number of test cases.
The first line of each test case contains two integers \(n\) and \(m\) - denoting the number of rows, and columns grid has.
The following \(n\) lines of each test case contain a string of length m having characters as either '0' or '1'.
It is guaranteed that the sum of \(n*m\) across all test cases doesn't exceed \(10^7\).
OUTPUT FORMAT
For each test case, print the answer modulo \(10^9 + 7\) in a new line.
Constraints
\(1<=t<=100\)
\(1<=n,m<=10^7\) and sum of \(n*m\) across all test cases <= \(10^7\)
Each cell in Grid is either 0 or 1
3 4 5 11101 01111 10101 10111 2 3 101 010 4 4 1111 1111 1111 1111
3 0 8
- Test case 1: There are three crosses as shown below.
- Test case 2: There is no cross.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor