You are given two grids, A and B, each with $H$ rows and $W$ columns.
For each pair of integers $(i, j)$ satisfying $1 \leq i \leq H$ and $1 \leq j \leq W$, let $(i, j)$ denote the cell in the $i$\-th row and $j$\-th column. In grid A, cell $(i, j)$ contains the integer $A_{i, j}$. In grid B, cell $(i, j)$ contains the integer $B_{i, j}$.
You will repeat the following operation any number of times, possibly zero. In each operation, you perform one of the following:
* Choose an integer $i$ satisfying $1 \leq i \leq H-1$ and swap the $i$\-th and $(i+1)$\-th rows in grid A.
* Choose an integer $i$ satisfying $1 \leq i \leq W-1$ and swap the $i$\-th and $(i+1)$\-th columns in grid A.
Determine whether it is possible to make grid A identical to grid B by repeating the above operation. If it is possible, print the minimum number of operations required to do so.
Here, grid A is identical to grid B if and only if, for all pairs of integers $(i, j)$ satisfying $1 \leq i \leq H$ and $1 \leq j \leq W$, the integer written in cell $(i, j)$ of grid A is equal to the integer written in cell $(i, j)$ of grid B.
## Constraints
* All input values are integers.
* $2 \leq H, W \leq 5$
* $1 \leq A_{i, j}, B_{i, j} \leq 10^9$
## Input
The input is given from Standard Input in the following format:
$H$ $W$
$A_{1, 1}$ $A_{1, 2}$ $\cdots$ $A_{1, W}$
$A_{2, 1}$ $A_{2, 2}$ $\cdots$ $A_{2, W}$
$\vdots$
$A_{H, 1}$ $A_{H, 2}$ $\cdots$ $A_{H, W}$
$B_{1, 1}$ $B_{1, 2}$ $\cdots$ $B_{1, W}$
$B_{2, 1}$ $B_{2, 2}$ $\cdots$ $B_{2, W}$
$\vdots$
$B_{H, 1}$ $B_{H, 2}$ $\cdots$ $B_{H, W}$
[samples]