Yuuka is playing "Tube Master". The game field is divided into n×m cells and (n+1)×(m+1) crossings connected by (n+1)×m horizontal tubes and n×(m+1) vertical ones. The cells are conveniently labeled with (i,j) for 1≤i≤n, 1≤j≤m, and the crossings are labeled with (i,j) for 1≤i≤(n+1), 1≤j≤(m+1). Additionally, each cell (i,j) contains an integer count_i,j.

Yuuka decides to use some of the tubes. However, the game poses several weird restrictions.
Using the tube connecting crossing (i,j) and (i,j+1) costs a_i,j, and using the tube connecting crossing (i,j) and (i+1,j) costs b_i,j. Yuuka would like to find a configuration satisfying the above constrains with the minimum possible total cost.
The input contains zero or more test cases, and is terminated by end-of-file. For each test case:
The first line contains two integers n and m (1≤n,m≤100).
The i-th of the following n lines contains m integers count_i,1,count_i,2,…,count_i,m (0≤count_i,j≤4).
The i-th of the next (n+1) lines contains m integers a_i,1,a_i,2,…,a_i,m.
The i-th of the last n lines contains (m+1) integers b_i,1,b_i,2,…,b_i,m+1.
The constraints are: 1≤a_i,j,b_i,j≤109.
It is guaranteed that the total sum of n⋅m in all test cases does not exceed 104.
For each test case, output an integer which denotes the minimum cost of the configuration. If there is no valid configuration, output "-1" instead.