题号:NC219804
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld
题目描述
You are given a matrix of

rows and

columns, for each grid
(1%5Cleq%20i%2Cj%5Cleq3)_%7B%7D)
, there is an integer on it, and the other grids are empty.
One of the way to set up flags in the second sample.
You have to set up flags in empty grids. For the grid with an integer on it, the amount of flags in the surrounding

grids needs to be equal to this integer.
Please calculate how many ways to set up the flag, two ways are considered different if and only if at least one flag is seted up in a different grid.
输入描述:
The first line contains an integer
— the number of test cases, each test case given a matrix of
rows and
columns,
representing the integer on grid
.
输出描述:
For each test case, please output an integer to indicate how many ways to set up the flags.