There are n×n cells on a grid, the top-left cell is at (1,1) while the bottom-right cell is at (n,n). In the cell (i,j) which is at row i and column j, there are (n2)a_i,j diamonds.
You start at (1,1) and move to (n,n). At any cell (i,j), you can move to (i+1,j) or (i,j+1), provided that you don't move out of the grid. Clearly, you will make exactly 2n−2 steps. When you are at a cell, you can take all the diamonds at this cell, including the starting point (1,1) and the destination (n,n).
However, some cells are blocked, but you don't know which cells are blocked. Please write a program to answer q queries. In each query, you will be given four integers r_1, r_2, c_1, c_2, and you need to report the maximum number of diamonds that you can take without passing the cells (i,j) such that r_1≤i≤r_2 and c_1≤j≤c_2.
The first line contains a single integer T (1≤T≤5), the number of test cases. For each test case:
The first line contains two integers n and q (2≤n≤400, 1≤q≤200,000) denoting the size of the grid and the number of queries.
Each of the following n lines contains n integers, the i-th line contains a_i,1,a_i,2,…,a_i,n (1≤a_i,j≤n2) denoting the number of diamonds in each cell.
Each of the following q lines contains four integers r_1, r_2, c_1, c_2 (1≤r_1≤r_2≤n, 1≤c_1≤c_2≤n) describing a query. It is guaranteed that you can find at least one valid path in each query.
For each query, print a single line containing an integer: the maximum number of diamonds that you can take. Note that the answer may be extremely large, so please print it modulo 109+7 instead.