human
A matrix of size n × m is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers (a_1, a_2, ... , a_k) is a palindrome, if for any integer i (1 ≤ i ≤ k) the equality a_i = a_{k - i + 1} holds.

Sasha owns a matrix a of size n × m. In one operation he can increase or decrease any number in the matrix by one. Sasha wants to make the matrix nice. He is interested what is the minimum number of operations he needs.

Help him!

Input

The first line contains a single integer t — the number of test cases (1 ≤ t ≤ 10). The t tests follow.

The first line of each test contains two integers n and m (1 ≤ n, m ≤ 100) — the size of the matrix.

Each of the next n lines contains m integers a_{i, j} (0 ≤ a_{i, j} ≤ 10^9) — the elements of the matrix.

Output

For each test output the smallest number of operations required to make the matrix nice.

Example

Input

2
4 2
4 2
2 4
4 2
2 4
3 4
1 2 3 4
5 6 7 8
9 10 11 18

Output

8
42

Note

In the first test case we can, for example, obtain the following nice matrix in 8 operations:
    
    
      
    2 2  
    4 4  
    4 4  
    2 2  
    

In the second test case we can, for example, obtain the following nice matrix in 42 operations:
    
    
      
    5 6 6 5  
    6 6 6 6  
    5 6 6 5  
    

=====
Give me a the minimum number of operations he needs?
assistant
#Here is the minimum number of operations he needs.

# _______________________________________________________________#
from math import *
import threading
import sys

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1

	while (start <= end):
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer  # index where x is not less than num

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1

	while (start <= end):
		middle = (end + start) // 2

		if li[middle] <= num:
			answer = middle
			start = middle + 1

		else:
			end = middle - 1
	return answer  # index where x is not greater than num

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while (lb <= ub):
		mid = (lb + ub) // 2
		# print(mid, li[mid])
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:	
			lb = mid + 1
		else:
			ans = mid # return index
			break
	return ans

def kadane(x):  # maximum sum contiguous subarray
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		a, b = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj

def SieveOfEratosthenes(n):
	prime = [True for i in range(n+1)]
	p = 2
	li = []
	while (p * p <= n):
		if (prime[p] == True):
			for i in range(p * p, n+1, p):
				prime[i] = False
		p += 1

	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li

# _______________________________________________________________#

INF = 1e9
# sys.setrecursionlimit(900000)
# threading.stack_size(10**5)  # remember it cause mle
# def main():
primes = SieveOfEratosthenes(1300000)
def fn(n):
	i = 2
	res =...