Due to the COVID pandemic, maintaining social distancing is of utmost importance. In this problem, you'd calculate how many days would it take to reach an apocalypse from an initial case if nobody maintains social distancing.
The Earth is flat (for this question) and it's dimensions are $R$ x $C$
The whole Earth is already divided into blocks and the virus can spread in all directions except diagonally. The virus from each newly infected person will spread in all directions in the next day, thus growing exponentially.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Next line contains $R$ and $C$ respectively separated by a space.
- Next line contains $x$ and $y$ respectively separated by a space, denoting the indices of the initial case in the world.

-----Output:-----
For each testcase, output in a single line an integer denoting the number of days after which everyone will be infected.

-----Constraints-----
- $1 \leq T \leq 10^4$
- $2 \leq R,C \leq 10^7$
- $0 \leq x,y \leq 10^7$

-----Subtasks-----
- 10 points : $1 \leq T \leq 5$ and $2 \leq R,C \leq 10$
- 20 points : $2 \leq R,C \leq 10^5$
- 70 points : Original constraints

-----Sample Input:-----
2
4 5
2 1
3 4
1 1

-----Sample Output:-----
5
3

-----EXPLANATION:-----
2nd test case:
Assuming, it's a small world of $3$ x $4$
0 is not infected. 1 is infected.
World indexing is like a 2D array:
(0,0) (0,1) (0,2) (0,3)
(1,0) (1,1) (1,2) (1,3)
(2,0) (2,1) (2,2) (2,3)
If this is the case on Day 0:
0 0 0 0
0 1 0 0
0 0 0 0
This will be the case on Day 1:
0 1 0 0
1 1 1 0
0 1 0 0
This will be the case on Day 2:
1 1 1 0
1 1 1 1
1 1 1 0
The End on Day 3:
1 1 1 1
1 1 1 1
1 1 1 1
Thus, answer will be 3

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
try:
	for _ in range(int(input())):
		(row, column) = list(map(int, input().split(' ')))
		(x_x, y_y) = list(map(int, input().split(' ')))
		ab = max(x_x - 0, row - x_x - 1)
		ba = max(y_y - 0, column - y_y - 1)
		print(ab + ba)
except:
	pass


from sys import stdin, stdout

def main():
	for _ in range(int(input())):
		(r, c) = map(int, input().split())
		(x, y) = map(int, input().split())
		res1 = max(r - 1 - x, x)
		res2 = max(c - 1 - y, y)
		print(res1 + res2)
main()


try:
	for _ in range(int(input())):
		(r, co) = list(map(int, input().split()))
		(x, y) = list(map(int, input().split()))
		a = y
		b = x
		c = co - a - 1
		d = r - b - 1
		p = max(b, d)
		q = max(a, c)
		k = max(p, q)
		print(p + q)
except:
	pass


T = int(input())
for _ in range(T):
	(r, c) = list(map(int, input().split()))
	(x, y) = list(map(int, input().split()))
	result = max(r - 1 - x, x) + max(c - 1 - y, y)
	print(result)


for _ in range(int(input())):
	(r, c) = map(int, input().split())
	(x, y) = map(int, input().split())
	print(max(x + y, r - x - 1 + y, c - y - 1 + x, r - x - 1 + c - y - 1))


for i in range(int(input())):
	(r, c) = list(map(int, input().split()))
	(y, x) = list(map(int, input().split()))
	s1 = x + y
	s2 = y + (c - x - 1)
	s3 = c - x - 1 + (r - y - 1)
	s4 = x + (r - y - 1)
	print(max(s1, s2, s3, s4))


for t in range(int(input())):
	(r, c) = map(int, input().split())
	(x, y) = map(int, input().split())
	print(max(abs(c - y - 1), y) + max(abs(r - x - 1), x))


for u in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	m = max(y - 1 - b, b)
	r = max(x - a - 1, a)
	print(m + r)


try:
	for _ in range(int(input())):
		(r, c) = map(int, input().split(' '))
		(x, y) = map(int, input().split(' '))
		a = max(x - 0, r - x - 1)
		b = max(y - 0, c - y - 1)
		print(a + b)
except:
	pass


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	(r, c) = list(map(int, input().split()))
	n -= 1
	m -= 1
	s1 = m - r + n - c
	s2 = r + c
	s3 = r + m - c
	s4 = n - r + c
	print(max(s1, s2, s3, s4))


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	(x, y) = list(map(int, input().split()))
	n -= 1
	m -= 1
	print(max(n - x, x) + max(y, m - y))


try:
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		w = c + d
		x = b - 1 - d + c
		y = a - 1 - c + d
		z = a - 1 - c + (b - 1 - d)
		print(max(w, x, y, z))
except:
	pass


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	(x, y) = [int(x) for x in input().split()]
	ss = max(x + y, x + m - y - 1, y + n - x - 1, m + n - x - y - 2)
	print(ss)


T = int(input())
output = []
for t in range(T):
	(R, C) = list(map(int, input().strip().split()))
	(x, y) = list(map(int, input().strip().split()))
	corners = [[0, 0], [0, C - 1], [R - 1, 0], [R - 1, C - 1]]
	distances = []
	for corner in corners:
		dis = abs(x - corner[0]) + abs(y - corner[1])
		distances.append(dis)
	days = max(distances)
	output.append(days)
for x in output:
	print(x)


t = int(input())
while t > 0:
	(r, c) = list(map(int, input().split()))
	(x, y) = list(map(int, input().split()))
	x += 1
	y += 1
	a = max(x - 1, r - x)
	b = max(y - 1, c - y)
	print(a + b)
	t -= 1


for ii in range(int(input())):
	(r, c) = list(map(int, input().split()))
	(x, y) = list(map(int, input().split()))
	mw = max(abs(y - c + 1), y)
	mh = max(abs(x - r + 1), x)
	print(mw + mh)


for t in range(int(input())):
	(R, C) = list(map(int, input().split()))
	(x, y) = list(map(int, input().split()))
	l = [x + y, R - 1 - x + y, C - y - 1 + x, R - x + C - y - 2]
	print(max(l))


for _ in range(int(input())):
	(r, c) = map(int, input().split())
	r = r - 1
	c = c - 1
	max = -1 * 10 ** 9
	(x, y) = map(int, input().split())
	xx = [0, r, 0, r]
	yy = [0, 0, c, c]
	for i in range(4):
		d = abs(x - xx[i]) + abs(y - yy[i])
		if d > max:
			max = d
	print(max)