# T-covering If you have ever played Tetris, you might know that one of the figures looks as follows: ![](https://i.imgur.com/A2wfZ9p.png) We will call this figure a *T-tetromino*; a *tetromino* is just a fancy word for a connected geometric figure composed of four cells. The cell marked with $\times$ will be called the *center cell*. Manca draws a rectangular grid with $m$ rows and $n$ columns and writes a number into each cell. She also marks some cells as *special*, e.g., by painting them red. After that, she asks Nika, a friend of hers, to place T-tetrominoes on the grid in such a way that the following conditions are met: * The number of T-tetrominoes has to be the same as the number of special cells. For each T-tetromino, its center cell has to lie on some special cell. * No pair of T-tetrominoes may overlap. * All T-tetrominoes have to completely lie on the grid. Note that there are four possible orientations of each T-tetromino ($\top$, $\bot$, $\vdash$, and $\dashv$). If the conditions cannot be satisfied, Nika should answer *No*; if they can, she has to find such a placement of T-tetrominoes that the sum of the numbers in the cells covered by the T-tetrominoes is maximum possible. In this case, she has to tell Manca the maximum sum. Write a program to help Nika solve the riddle. ## Input Each line contains a sequence of integers separated by a single space. The first line of the input contains the integers $m$ and $n$. Each of the following $m$ lines contains $n$ integers from the interval $[0, 1000]$. The $j$-th integer ($j \in \{1, \ldots, n\}$) in the $i$-th line ($i \in \{1, \ldots, m\}$) represents the number written in the $j$-th cell of the $i$-th row of the grid. The next line contains an integer $k \in \{1$, $mn\}$. This line is followed by $k$ more lines, each of which consists of integers $r_i \in \{0, \ldots, m - 1\}$ and $c_i \in \{0, \ldots, n - 1\}$, which represent the position (the row index and column index, respectively) of the $i$-th special cell. ## Output Print the maximum possible sum of the numbers in the cells covered by the T-tetrominoes, or ``No`` if no valid placement of T-tetrominoes exists. ## Constraints * $1 \le mn \le 10^6$. ## Subtasks * **5 points:** $k \le 1000$; for each pair $(i, j)$ of special cells, we have $|r_i - r_j| > 2$ or $|c_i - c_j| > 2$. * **10 points:** $k \le 1000$; for each pair $(i, j)$ of special cells, it holds that if $|r_i - r_j| \le 2$ and $|c_i - c_j| \le 2$, then $|r_i - r_j| = 1$ and $|c_i - c_j| = 0$ or $|r_i - r_j| = 0$ and $|c_i - c_j| = 1$. * **10 points:** $k \le 1000$; for each pair $(i, j)$ of special cells, it holds that if $|r_i - r_j| \le 2$ and $|c_i - c_j| \le 2$, then $|r_i - r_j| \le 1$ and $|c_i - c_j| \le 1$. * **10 points:** $k \le 1000$; all special cells lie in the same row. * **15 points:** $k \le 10$. * **20 points:** $k \le 1000$. * **30 points:** no additional constraints. ## Example 1 ### Input ``` 5 6 7 3 8 1 0 9 4 6 2 5 8 3 1 9 7 3 9 5 2 6 8 4 5 7 3 8 2 7 3 6 3 1 1 2 2 3 4 ``` ### Output ``` 67 ``` ### Comment To achieve the maximum sum, Nika may place the tetrominoes as follows: * $\dashv$ on the cell (1, 1); * $\vdash$ on the cell (2, 2); * $\bot$ on the cell (3, 4). ## Example 2 ### Input ``` 5 6 7 3 8 1 0 9 4 6 2 5 8 3 1 9 7 3 9 5 2 6 8 4 5 7 3 8 2 7 3 6 3 1 1 2 2 3 3 ``` ### Output ``` No ```