There are $$$n \times m$$$ crossroads in the city, named crossroad $$$(1, 1), (1, 2),\ldots, (n, m)$$$. The first number represents the row, and the second represents the column.
There exists and only exists streets between $$$(i,j)$$$ and $$$(i+1,j)$$$ or between $$$(i,j)$$$ and $$$(i,j+1)$$$. The street between $$$(i, j)$$$ and $$$(i + 1, j)$$$ has a weight of $$$w_{i,j}$$$, and the street between $$$(i, j)$$$ and $$$(i, j + 1)$$$ has a weight of $$$v_{i,j}$$$.
Simons wants some streets reconstructed. Due to some accidents, some of the streets cannot be reconstructed, while others are optional to be reconstructed.
For each crossroad, if the number of reconstructed streets adjacent to it is even, Simons calls the crossroad elegant. If all the crossroads are elegant, Simons calls the reconstruction nice.
The beauty of a reconstruction is calculated as follows:
In other words, if a street is an odd-indexed one reconstructed in its row or column, add its weight to the beauty; else subtract it from the beauty.
For example, consider the streets and crossroads below without any streets that cannot be reconstructed:
We can have a nice reconstruction as follows:
The beauty of the reconstruction is $$$3+4+2-(-9)-(-2)+9+1-(-1)-(-3)-(-4)=38$$$.
Help Simons find the maximum beauty among all the nice reconstructions.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5\cdot 10^4$$$). The description of the test cases follows.
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2\le n,m\le 2\cdot 10^5$$$; $$$n\cdot m\le 4\cdot 10^5$$$) — the number of rows and columns.
In the next $$$n-1$$$ lines, each line contains $$$m$$$ integers $$$w_{i,j}$$$ ($$$-10^9\le w_{i,j}\le 10^9$$$) — the weights of the street between $$$(i,j)$$$ and $$$(i+1,j)$$$.
In the next $$$n$$$ lines, each line contains $$$m-1$$$ integers $$$v_{i,j}$$$ ($$$-10^9\le v_{i,j}\le 10^9$$$) — the weights of the street between $$$(i,j)$$$ and $$$(i,j+1)$$$.
In the next $$$n-1$$$ lines, each line contains $$$m$$$ characters $$$p_{i,j}$$$ ($$$p_{i,j}\in\{\texttt{0},\texttt{1}\}$$$) — if $$$p_{i,j}=\texttt{0}$$$, the street between $$$(i,j)$$$ and $$$(i+1,j)$$$ cannot be reconstructed, and vice versa.
In the next $$$n$$$ lines, each line contains $$$m-1$$$ characters $$$q_{i,j}$$$ ($$$q_{i,j}\in\{\texttt{0},\texttt{1}\}$$$) — if $$$q_{i,j}=\texttt{0}$$$, the street between $$$(i,j)$$$ and $$$(i,j+1)$$$ cannot be reconstructed, and vice versa.
It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$4\cdot 10^5$$$.
For each test case, output a single integer — the maximum beauty among all the nice reconstructions.
43 42 3 -2 34 9 4 -43 4 -2-9 -5 16 -1 -3111111111111111112 44 23 1 356 12 -17-14 1 -4001000001013 31 0 10 1 01 00 10 01101111011113 413 7 6 -123 -5 12 -6-3 10 -15-5 8 -1110 0 -511110110110101010
38048
The first test case is explained in the statement.
In the second test case, there is only one nice reconstruction: Simons reconstructs no street. So the maximum beauty is $$$0$$$.