#P9857. Meadow
Meadow
Meadow
Problem Description
There is A size meadow. For each location , if , it means that this location is planted with grass, and vice versa it means that this location is not planted with grass. If some location is covered by a grass-covered (completely covered with grass) square area of size , the energy of the meadow will increase (the energy can be increased multiple times if a position covered by different square areas that meet the requirements). You need to calculate the energy of the whole meadow.
Input
For the first line,input a positive integer , representing the total number of test data. For each test data, input two positive integers and () in the first line, representing the size of the meadow. The next line, each integer, input matrix , representing whether there is planted with grass in this position. The next line, each integer, input matrix , representing the weight of each position.
Output
Output a line of a integer, representing the energy sum of the meadow, the answer may be large, need to modulus . "scanf" and "printf" are slower in this OJ and are not recommended for submission
Sample Input
1
3 3
1 1 0
0 1 1
1 1 1
1 2 3
4 5 6
7 8 9
Sample Output
94
Source
2023“钉耙编程”中国大学生算法设计超级联赛(6)