There are $n \times 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 at $(i,j)$, there are $\left(n^2\right)^{a_{i,j}}$ diamonds.
Initially, you are at $(1,1)$, every time you can move to $(i+1,j)$ or $(i,j+1)$ from $(i,j)$ without moving out of the grid. Your destination is at $(n,n)$, so you will take exactly $2n-2$ moves. When you are at a cell, you can take all the diamonds inside 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 $xl,xr,yl,yr$, you need to report the maximum number of diamonds that you can take without passing the cells $(i,j)$ such that $xl\leq i\leq xr$ and $yl\leq j\leq yr$.