Striver$Striver$ wants to strive hard in order to reach his goals, hence asks his mentor to give him a question for which he has to strive hard. 
The mentor gives Striver$Striver$ a N$N$ X N$N$ matrix consisting of lowercase characters (′a′$'a'$ to ′z′$'z'$) and Q$Q$ queries. Every query consists of X$X$ and Y$Y$. From any position in the matrix, one can either move towards the right or towards down. He asks striver to write down all the paths from (1,1)$(1, 1)$ to (X,Y)$(X, Y)$ and find out which string has the maximum number of character ′a′$'a'$ in it and answer him the number of characters which are not 'a' in that string. 
Striver wants to strive hard but also wants to impress his mentor. He asks for your help to answer Q$Q$ queries given by his mentor as fast as he can so that he can impress his mentor also. Can you help him to answer the Q queries?

-----Input:-----
- First line will contain T$T$, number of test cases. Then the test cases follow. 
- First line of every test case contains a number N$N$ and Q$Q$ which denotes the dimensions of the matrix and number of queries respectively.  
- N lines follow, which contains N numbers each denoting the elements of the matrix. 
- Q line follow, every line contains X and Y. 

-----Output:-----
For every test case, print a single integer which prints the answer to mentor's every query. 

-----Constraints-----
- 1≤T≤10$1 \leq T \leq 10$
- 1≤N≤103$1 \leq N \leq 10^3$
- 1≤Q≤105$1 \leq Q \leq 10^5$
- 1≤X,Y≤N$1 \leq X, Y \leq N$

-----Sample Input:-----
1
3 2 
a b a 
a c d 
b a b
1 3
3 3 

-----Sample Output:-----
1 
2

-----EXPLANATION:-----
Query-1: There is only one path from (1,1) to (1,3) i.e.,"aba" and the number of characters which are not 'a' is 1. 
Query-2:  The path which has the maximum number of 'a' in it is "aabab", hence non 'a' characters are 2.

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
a = int(input())
for _ in range(a):
	(c, d) = list(map(int, input().split()))
	crr = [[[0, 0] for i in range(c + 1)] for j in range(c + 1)]
	trr = []
	for i in range(c):
		kk = list(input().split())
		trr.append(kk)
	for i in range(1, c + 1):
		for j in range(1, c + 1):
			if trr[i - 1][j - 1] == 'a':
				crr[i][j][0] = max(crr[i - 1][j][0], crr[i][j - 1][0]) + 1
				if j == 1:
					crr[i][j][1] = crr[i - 1][j][1] + 1
				elif i == 1:
					crr[i][j][1] = crr[i][j - 1][1] + 1
				elif crr[i - 1][j][0] > crr[i][j - 1][0]:
					crr[i][j][1] = crr[i - 1][j][1] + 1
				else:
					crr[i][j][1] = crr[i][j - 1][1] + 1
			else:
				crr[i][j][0] = max(crr[i - 1][j][0], crr[i][j - 1][0])
				if j == 1:
					crr[i][j][1] = crr[i - 1][j][1] + 1
				elif i == 1:
					crr[i][j][1] = crr[i][j - 1][1] + 1
				elif crr[i - 1][j][0] > crr[i][j - 1][0]:
					crr[i][j][1] = crr[i - 1][j][1] + 1
				else:
					crr[i][j][1] = crr[i][j - 1][1] + 1
	for i in range(d):
		(m, n) = list(map(int, input().split()))
		print(crr[m][n][1] - crr[m][n][0])


t = int(input())
for _ in range(t):
	(n, q) = list(map(int, input().split()))
	main = [[0] * (n + 1)]
	final = [[0] * (n + 1)]
	const = [[0] * (n + 1)]
	for i in range(n):
		l = [0] * (n + 1)
		z = [0] * (n + 1)
		w = list(input().split())
		w.insert(0, 0)
		final.append(w)
		main.append(l)
		const.append(z)
	for i in range(1, n + 1):
		for j in range(1, n + 1):
			main[i][j] = max(main[i - 1][j], main[i][j - 1])
			if final[i][j] == 'a':
				main[i][j] += 1
			if main[i - 1][j] > main[i][j - 1]:
				const[i][j] += const[i - 1][j]
			else:
				const[i][j] += const[i][j - 1]
			if final[i][j] != 'a':
				const[i][j] += 1
	for i in range(q):
		(s, d) = list(map(int, input().split()))
		print(s + d - 1 - main[s][d])


t = int(input())
for sai in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = []
	for i in range(n):
		a.append(input().split())
	for i in range(n):
		for j in range(n):
			if a[i][j] == 'a':
				a[i][j] = [1, -1]
			else:
				a[i][j] = [0, -1]
	a[0][0][1] = 1
	for i in range(1, n):
		a[0][i][0] = a[0][i - 1][0] + a[0][i][0]
		a[0][i][1] = a[0][i - 1][1] + 1
	for i in range(1, n):
		a[i][0][0] = a[i - 1][0][0] + a[i][0][0]
		a[i][0][1] = a[i - 1][0][1] + 1
	for i in range(1, n):
		for j in range(1, n):
			if a[i - 1][j][0] > a[i][j - 1][0]:
				a[i][j][0] = a[i - 1][j][0] + a[i][j][0]
				a[i][j][1] = a[i - 1][j][1] + 1
			else:
				a[i][j][0] = a[i][j - 1][0] + a[i][j][0]
				a[i][j][1] = a[i][j - 1][1] + 1
	for i in range(m):
		(p, q) = [int(x) for x in input().split()]
		print(a[p - 1][q - 1][1] - a[p - 1][q - 1][0])