Wabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point $(x_1,y_1)$ to the point $(x_2,y_2)$.

He has a rope, which he can use to pull the box. He can only pull the box if he stands exactly $1$ unit away from the box in the direction of one of two coordinate axes. He will pull the box to where he is standing before moving out of the way in the same direction by $1$ unit.  [Image] 

For example, if the box is at the point $(1,2)$ and Wabbit is standing at the point $(2,2)$, he can pull the box right by $1$ unit, with the box ending up at the point $(2,2)$ and Wabbit ending at the point $(3,2)$.

Also, Wabbit can move $1$ unit to the right, left, up, or down without pulling the box. In this case, it is not necessary for him to be in exactly $1$ unit away from the box. If he wants to pull the box again, he must return to a point next to the box. Also, Wabbit can't move to the point where the box is located.

Wabbit can start at any point. It takes $1$ second to travel $1$ unit right, left, up, or down, regardless of whether he pulls the box while moving.

Determine the minimum amount of time he needs to move the box from $(x_1,y_1)$ to $(x_2,y_2)$. Note that the point where Wabbit ends up at does not matter.


-----Input-----

Each test contains multiple test cases. The first line contains a single integer $t$ $(1 \leq t \leq 1000)$: the number of test cases. The description of the test cases follows.

Each of the next $t$ lines contains four space-separated integers $x_1, y_1, x_2, y_2$ $(1 \leq x_1, y_1, x_2, y_2 \leq 10^9)$, describing the next test case.


-----Output-----

For each test case, print a single integer: the minimum time in seconds Wabbit needs to bring the box from $(x_1,y_1)$ to $(x_2,y_2)$.


-----Example-----
Input
2
1 2 2 2
1 1 2 2

Output
1
4



-----Note-----

In the first test case, the starting and the ending points of the box are $(1,2)$ and $(2,2)$ respectively. This is the same as the picture in the statement. Wabbit needs only $1$ second to move as shown in the picture in the statement.

In the second test case, Wabbit can start at the point $(2,1)$. He pulls the box to $(2,1)$ while moving to $(3,1)$. He then moves to $(3,2)$ and then to $(2,2)$ without pulling the box. Then, he pulls the box to $(2,2)$ while moving to $(2,3)$. It takes $4$ seconds.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
for t in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		ans += 2
	print(ans)


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	ans = abs(a - c) + abs(d - b)
	if a != c and b != d:
		ans = ans + 2
	print(ans)


import sys
read = sys.stdin.read

def main():
	t = int(input())
	m = map(int, read().split())
	for (x1, y1, x2, y2) in zip(m, m, m, m):
		if x1 == x2 and y1 == y2:
			print(0)
		else:
			ans = abs(x1 - x2) + abs(y1 - y2) + 2
			if x1 == x2 or y1 == y2:
				ans -= 2
			print(ans)
main()


t = int(input())
for _ in range(t):
	lis = list(map(int, input().split()))
	x1 = lis[0]
	y1 = lis[1]
	x2 = lis[2]
	y2 = lis[3]
	x = abs(x1 - x2)
	y = abs(y1 - y2)
	if x * y == 0:
		print(x + y)
	else:
		print(x + y + 2)


t = int(input(''))
for _ in range(t):
	[x1, y1, x2, y2] = list(map(int, input().split()))
	sol1 = 0
	sol2 = 0
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		sol1 += abs(x1 - x2) + 1
		sol1 += abs(y2 - y1) + 1
		print(sol1)


T = int(input())
for t in range(1, T + 1):
	(x, y, u, v) = map(int, input().split())
	if x == u or y == v:
		d = abs(x - u) + abs(y - v)
	else:
		d = abs(x - u) + abs(y - v) + 2
	print('{}'.format(d))


for t in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	x_diff = abs(x1 - x2)
	y_diff = abs(y1 - y2)
	if x_diff == 0 or y_diff == 0:
		print(x_diff + y_diff)
	else:
		print(x_diff + y_diff + 2)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	s = abs(x2 - x1) + abs(y2 - y1)
	if x1 != x2 and y1 != y2:
		s += 2
	print(s)


x = int(input())
ansl = []
for i in range(x):
	(xone, yone, xtwo, ytwo) = map(int, input().split())
	if xone == xtwo or yone == ytwo:
		if xone == xtwo:
			ansl.append(abs(yone - ytwo))
		else:
			ansl.append(abs(xone - xtwo))
	else:
		ansl.append(abs(xone - xtwo) + abs(yone - ytwo) + 2)
for i in ansl:
	print(i)


t = int(input())
for _ in range(t):
	dim = list(map(int, input().split()))
	if dim[1] == dim[3]:
		print(max(dim[0], dim[2]) - min(dim[0], dim[2]))
	elif dim[0] == dim[2]:
		print(max(dim[1], dim[3]) - min(dim[1], dim[3]))
	else:
		v1 = max(dim[0], dim[2]) - min(dim[0], dim[2])
		v2 = max(dim[1], dim[3]) - min(dim[1], dim[3])
		print(v1 + v2 + 2)


import math
n = int(input())
for _ in range(n):
	l = input().split()
	l = [int(x) for x in l]
	x1 = l[0]
	y1 = l[1]
	x2 = l[2]
	y2 = l[3]
	x = 0
	if x1 != x2 and y1 != y2:
		x = 2
	print(abs(x1 - x2) + abs(y1 - y2) + x)


n = int(input())
for i in range(n):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 != x2 and y1 == y2:
		print(abs(x2 - x1))
	elif x1 == x2 and y1 != y2:
		print(abs(y2 - y1))
	elif x1 == x2 and y1 == y2:
		print(0)
	else:
		print(abs(x2 - x1) + 2 + abs(y2 - y1))


t = int(input())
for i in range(t):
	(xa, ya, xb, yb) = map(int, input().split())
	if xa == xb:
		print(abs(ya - yb))
	elif ya == yb:
		print(abs(xa - xb))
	else:
		print(2 + abs(xa - xb) + abs(ya - yb))


t = int(input())
ans = []
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	ans1 = 0
	if x1 - x2 == 0 or y1 - y2 == 0:
		ans1 = abs(x1 - x2) + abs(y1 - y2)
	else:
		ans1 = abs(x1 - x2) + abs(y1 - y2) + 2
	ans.append(ans1)
for i in ans:
	print(i)


testcases = int(input())
for testcase in range(testcases):
	temparr = input()
	temparr = temparr.split()
	x = int(temparr[0])
	y = int(temparr[1])
	ex = int(temparr[2])
	ey = int(temparr[3])
	if y == ey:
		print(abs(ex - x))
		continue
	if x == ex:
		print(abs(ey - y))
		continue
	ans = abs(ey - y) + abs(ex - x) + 2
	print(ans)


import sys
input = lambda : sys.stdin.readline().strip()
for i in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = 0
	ans += abs(x1 - x2)
	ans += abs(y1 - y2)
	if y1 != y2 and x1 != x2:
		ans += 2
	print(ans)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(x1, y1, x2, y2) = getInts()
	if x1 == x2 and y1 == y2:
		return 0
	(dx, dy) = (abs(x1 - x2), abs(y1 - y2))
	ans = dx + dy
	if dx and dy:
		ans += 2
	return ans
for _ in range(getInt()):
	print(solve())


for i in range(int(input())):
	(a, b, c, d) = list(map(int, input().split()))
	if a == c:
		print(max(d, b) - min(d, b))
	elif b == d:
		print(max(a, c) - min(a, c))
	else:
		print(max(d, b) - min(d, b) + (max(a, c) - min(a, c)) + 2)


def moves(x1, y1, x2, y2):
	if x1 == x2:
		return abs(y2 - y1)
	elif y1 == y2:
		return abs(x2 - x1)
	return abs(x2 - x1) + abs(y2 - y1) + 2
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	print(moves(x1, y1, x2, y2))


def hi(x1, y1, x2, y2):
	if x1 == x2 and y1 == y2:
		return 0
	if abs(x1 - x2) == 0 or abs(y1 - y2) == 0:
		return max(abs(x1 - x2), abs(y1 - y2))
	return 2 + abs(x1 - x2) + abs(y1 - y2)
t = int(input())
b = []
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	b.append(hi(x1, y1, x2, y2))
for i in range(len(b)):
	print(b[i])


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve(x1, y1, x2, y2):
	res = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		res += 2
	return res
TC = int(input())
for tc in range(TC):
	(x1, y1, x2, y2) = map(int, input().split())
	res = solve(x1, y1, x2, y2)
	print(res)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	dx = abs(x2 - x1)
	dy = abs(y2 - y1)
	if dx == 0 and dy == 0:
		t = 0
	elif dx == 0:
		t = dy
	elif dy == 0:
		t = dx
	else:
		t = dx + dy + 2
	print(t)


def cal(x1, y1, x2, y2):
	c = abs(x2 - x1) + abs(y2 - y1)
	if y1 != y2 and x1 != x2:
		c += 2
	return int(c)
t = int(input())
c = []
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	r = cal(x1, y1, x2, y2)
	c.append(r)
for i in c:
	print(i)


t = int(input())
while t != 0:
	t -= 1
	res = 0
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 != x2 and y1 != y2:
		res += 2
	res += abs(x1 - x2) + abs(y1 - y2)
	print(res)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	if x1 - x2 != 0 and y1 - y2 != 0:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
	else:
		print(abs(x1 - x2) + abs(y1 - y2))


t = int(input())
for you in range(t):
	l = input().split()
	x1 = int(l[0])
	y1 = int(l[1])
	x2 = int(l[2])
	y2 = int(l[3])
	ans = abs(x2 - x1) + abs(y2 - y1)
	if x1 == x2 or y1 == y2:
		print(ans)
	else:
		print(ans + 2)


def solve():
	(x1, y1, x2, y2) = map(int, input().split())
	score = abs(x2 - x1)
	if y1 != y2:
		score += 2 if x1 != x2 else 0
		score += abs(y2 - y1)
	print(score)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


def do():
	import math
	q = int(input())
	for _ in range(q):
		(x1, y1, x2, y2) = map(int, input().split())
		if x1 == x2:
			print(abs(y1 - y2))
			continue
		if y1 == y2:
			print(abs(x1 - x2))
			continue
		res = abs(y1 - y2) + 2 + abs(x1 - x2)
		print(res)
		continue
do()


t = int(input())
for i in range(t):
	(p1, q1, p2, q2) = map(int, input().split())
	if p1 == p2:
		print(abs(q2 - q1))
	elif q2 == q1:
		print(abs(p2 - p1))
	else:
		res = abs(p2 - p1) + abs(q2 - q1) + 2
		print(res)


def solve():
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 and y1 == y2:
		return 0
	if x1 == x2:
		return abs(y2 - y1)
	if y1 == y2:
		return abs(x2 - x1)
	return abs(x2 - x1) + abs(y2 - y1) + 2
TC = int(input())
for _ in range(TC):
	print(solve())


for T in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		value = abs(y1 - y2)
	elif y1 == y2:
		value = abs(x1 - x2)
	else:
		value = abs(x1 - x2) + abs(y1 - y2) + 2
	print(value)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = 0
	if abs(x1 - x2) == 0 and abs(y1 - y2) == 0:
		print(ans)
	else:
		if abs(x1 - x2) == 0:
			ans += abs(y1 - y2)
		elif abs(y1 - y2) == 0:
			ans += abs(x1 - x2)
		else:
			ans += abs(x1 - x2) + abs(y1 - y2) + 2
		print(ans)


n = int(input())
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	if abs(a - c) * abs(b - d) > 0:
		print(abs(a - c) + abs(b - d) + 2)
	else:
		print(abs(a - c) + abs(b - d))


n = int(input())
for i in range(n):
	(x1, y1, x2, y2) = map(int, input().split())
	t = max(x2, x1) - min(x2, x1) + 2 + (max(y1, y2) - min(y1, y2))
	if x1 == x2 or y1 == y2:
		t = t - 2
	print(t)


import sys
input = sys.stdin.readline

def print(val):
	sys.stdout.write(str(val) + '\n')

def prog():
	for _ in range(int(input())):
		(x1, y1, x2, y2) = map(int, input().split())
		if x1 == x2:
			print(abs(y2 - y1))
		elif y1 == y2:
			print(abs(x1 - x2))
		else:
			print(abs(x1 - x2) + abs(y2 - y1) + 2)
prog()


import os, sys
from collections import defaultdict
from io import BytesIO, IOBase

def main():
	for i in range(int(input())):
		an = 0
		(a, b, c, d) = map(int, input().split())
		an += abs(a - c) + abs(b - d)
		if a != c and b != d:
			an += 2
		print(an)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if a == c or b == d:
		print(abs(a - c) + abs(b - d))
	else:
		print(abs(a - c) + abs(b - d) + 2)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

def solve():
	(x1, y1, x2, y2) = Scanner.map_int()
	x = abs(x2 - x1)
	y = abs(y2 - y1)
	ans = x + y
	if y > 0 and x > 0:
		ans += 2
	print(ans)

def main():
	T = Scanner.int()
	for _ in range(T):
		solve()
main()


t = int(input())
while t > 0:
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	if y1 == y2:
		print(abs(x2 - x1))
	elif x1 == x2:
		print(abs(y2 - y1))
	else:
		print(abs(x2 - x1) + 2 + abs(y2 - y1))
	t -= 1


for it in range(int(input())):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	ans = abs(x1 - x2) + abs(y1 - y2) + 2
	if x1 == x2 or y1 == y2:
		ans -= 2
	print(ans)


def func():
	t = int(input())
	for _ in range(t):
		(x1, y1, x2, y2) = map(int, input().strip().split())
		if x1 == x2 or y1 == y2:
			print(abs(x1 - x2) + abs(y1 - y2))
		else:
			print(abs(x1 - x2) + abs(y1 - y2) + 2)
func()


import math
T = int(input())
for t in range(T):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	d = False
	print(abs(x1 - x2) + abs(y2 - y1) + 2 * ((y2 != y1) * (x2 != x1)))


iin = lambda : int(input())
lin = lambda : list(map(int, input().rstrip().split()))
TEST_CASES = True

def main():
	(x1, y1, x2, y2) = lin()
	ans = 0
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
if not TEST_CASES:
	main()
else:
	[main() for _ in range(int(input()))]


t = int(input())
while t:
	(a, b, c, d) = map(int, input().split())
	if a >= c:
		m1 = a - c
	else:
		m1 = c - a
	if b >= d:
		m2 = b - d
	else:
		m2 = d - b
	if a == c or b == d:
		print(m1 + m2)
	else:
		print(m1 + m2 + 2)
	t -= 1


t = int(input())
for inh in range(0, t):
	(a, b, x, y) = map(int, input().split())
	dx = abs(a - x)
	dy = abs(b - y)
	if dx == 0 or dy == 0:
		print(dx + dy)
	else:
		print(dx + dy + 2)


T = int(input())
for z in range(T):
	(a, b, x, y) = [int(e) for e in input().split()]
	out = abs(a - x) + abs(b - y)
	if a != x and b != y:
		out += 2
	print(out)


def solve():
	(x1, y1, x2, y2) = (int(x) for x in input().split())
	dist = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		dist += 2
	print(dist)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 == x2 or y1 == y2:
		pass
	else:
		ans += 2
	print(ans)


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		print(abs(x2 - x1) + abs(y1 - y2))
	else:
		print(abs(x2 - x1) + abs(y1 - y2) + 2)


rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
yn = lambda x: print('Yes') if x else print('No')
YN = lambda x: print('YES') if x else print('NO')
pl = lambda l: print(' '.join(list(map(str, l))))
for _ in range(rn()):
	(a, b, c, d) = rns()
	x = abs(a - c)
	y = abs(b - d)
	ans = x + y
	if x != 0 and y != 0:
		ans += 2
	print(ans)


def duration_sec(coords):
	(x1, y1, x2, y2) = coords
	wabbit_move = 0 if abs(x2 - x1) == 0 or abs(y2 - y1) == 0 else 2
	return abs(x2 - x1) + abs(y2 - y1) + wabbit_move
t = int(input())
for _ in range(t):
	coords = [int(x) for x in input().split()]
	print(duration_sec(coords))


t = int(input())
for i in range(t):
	(x, y, a, b) = map(int, input().split())
	xdist = abs(x - a)
	ydist = abs(y - b)
	if ydist > 0 and xdist > 0:
		ydist += 2
	print(xdist + ydist)


import math
n = int(input())
for i in range(n):
	(a, b, c, d) = [int(i) for i in input().split()]
	e = abs(c - a)
	f = abs(d - b)
	ans = 0
	if f == 0:
		print(e)
	elif e == 0:
		print(f)
	else:
		print(e + 2 + f)


t = int(input())
while t:
	t -= 1
	(x1, y1, x2, y2) = list(map(int, input().strip().split()))
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


t = int(input())

def main():
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 and y1 == y2:
		print(0)
	elif x1 == x2 and y1 != y2:
		print(abs(y1 - y2))
	elif y1 == y2 and x1 != x2:
		print(abs(x1 - x2))
	else:
		print(1 + abs(x1 - x2) + abs(y1 - y2) + 1)
for i in range(t):
	main()


for u in range(int(input())):
	l = list(map(int, input().split()))
	x = abs(l[2] - l[0])
	y = abs(l[3] - l[1])
	if y == 0:
		print(x)
	elif x == 0:
		print(y)
	else:
		print(x + y + 2)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


n = int(input())
for i in range(n):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	if x1 == x2 or y1 == y2:
		print(max(abs(x1 - x2), abs(y1 - y2)))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


import math
T = int(input())
for test in range(T):
	inp = list(map(int, input().strip().split()))
	(x1, y1, x2, y2) = (inp[0], inp[1], inp[2], inp[3])
	x_diff = abs(x2 - x1)
	y_diff = abs(y2 - y1)
	cost = x_diff + y_diff
	if x_diff and y_diff:
		cost += 2
	print(cost)


from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + '\n')
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		ans += 2
	print(ans)


t = int(input())
for _ in range(t):
	(x, y, a, b) = map(int, input().split())
	if x == a or y == b:
		print(abs(x - a) + abs(y - b))
	else:
		print(abs(x - a) + abs(y - b) + 2)


import sys
input = sys.stdin.readline

def solve():
	(x1, y1, x2, y2) = map(int, input().split())
	return max(abs(x1 - x2), abs(y1 - y2)) if x1 == x2 or y1 == y2 else abs(x2 - x1) + abs(y2 - y1) + 2
for _ in range(int(input())):
	print(solve())


tt = int(input())
for t in range(tt):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	direction = 'R'
	moves = abs(x1 - x2)
	if moves != 0 and y1 != y2:
		moves += 2 + abs(y1 - y2)
	if moves == 0 and y1 != y2:
		moves = abs(y1 - y2)
	print(moves)


test_case_num = int(input())
for i in range(test_case_num):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(y1 - y2) + 2 + abs(x1 - x2))


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		print(abs(x2 - x1) + abs(y2 - y1))
	else:
		x = x1
		y = y2
		sum = 0
		sum += abs(x - x1)
		sum += abs(y - y1)
		sum += abs(x2 - x)
		sum += abs(y2 - y)
		print(sum + 2)


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = 0
	if x1 == x2 and y1 == y2:
		print(0)
	elif x1 == x2:
		print(max(y1, y2) - min(y1, y2))
	elif y1 == y2:
		print(max(x1, x2) - min(x1, x2))
	elif x1 < x2:
		ans += x2 - x1
		ans += 2
		ans += max(y1, y2) - min(y1, y2)
		print(ans)
	else:
		ans += x1 - x2
		ans += 2
		ans += max(y1, y2) - min(y1, y2)
		print(ans)


def count_time(s):
	if s[0] == s[2] or s[1] == s[3]:
		return abs(s[0] - s[2]) + abs(s[1] - s[3])
	else:
		return abs(s[0] - s[2]) + abs(s[1] - s[3]) + 2
for i in range(int(input())):
	print(count_time([int(i) for i in input().split()]))


for t in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if c - a != 0 and d - b != 0:
		print(abs(c - a) + abs(b - d) + 2)
	elif c - a != 0:
		print(abs(c - a))
	else:
		print(abs(d - b))


from sys import stdin
_input = stdin.readline
(_int, _abs, _range) = (int, abs, range)

def solution():
	for _ in _range(_int(_input())):
		(x_1, y_1, x_2, y_2) = [_int(i) for i in _input().split()]
		delta_x = _abs(x_2 - x_1)
		delta_y = _abs(y_2 - y_1)
		if delta_x == 0:
			print(delta_y)
		elif delta_y == 0:
			print(delta_x)
		else:
			print(delta_x + delta_y + 2)
solution()


game = int(input())
for i in range(game):
	(x1, x2, x3, x4) = map(int, input().split())
	if x3 - x1 == 0:
		print(abs(x4 - x2))
	elif x4 - x2 == 0:
		print(abs(x3 - x1))
	else:
		print(abs(x3 - x1) + abs(x4 - x2) + 2)


n = int(input())
for i in range(n):
	a = input()
	b = []
	b = a.split()
	b = [int(x) for x in b]
	xk = b[0]
	yk = b[1]
	konx = b[2]
	kony = b[3]
	t = abs(konx - xk) + abs(kony - yk)
	if yk != kony and xk != konx:
		t += 2
	print(t)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(x, y, u, v) = map(int, input().split())
	res = 0
	if x != u and y != v:
		res += 2
	res += abs(x - u) + abs(y - v)
	print(res)


rw = int(input())
for wewq in range(rw):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 and y1 == y2:
		print(0)
	elif x1 == x2 or y1 == y2:
		print(abs(x2 - x1) + abs(y2 - y1))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


t = int(input())
while t > 0:
	l = list()
	(x1, y1, x2, y2) = input().split()
	x1 = int(x1)
	y1 = int(y1)
	x2 = int(x2)
	y2 = int(y2)
	xdiff = abs(x2 - x1)
	ydiff = abs(y2 - y1)
	if xdiff == 0 or ydiff == 0:
		if xdiff == 0:
			print(ydiff)
		elif ydiff == 0:
			print(xdiff)
	elif xdiff != 0 and ydiff != 0:
		print(xdiff + ydiff + 2)
	t = t - 1


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	(x1, y1, x2, y2) = value()
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		res = abs(x1 - x2) + abs(y1 - y2) + 2
		print(res)


def get_data_a():
	n = int(input())
	digits = []
	for i in range(n):
		digits.append([int(num) for num in input().split()])
	return digits

def move_box(data_a):
	time = []
	for coord in data_a:
		x1 = coord[0]
		y1 = coord[1]
		x2 = coord[2]
		y2 = coord[3]
		if x1 - x2 == 0:
			time_in = abs(y1 - y2)
		elif y1 - y2 == 0:
			time_in = abs(x1 - x2)
		else:
			time_in = abs(x1 - x2) + abs(y1 - y2) + 2
		time.append(time_in)
	return time
data_a = get_data_a()
print('\n'.join([str(time) for time in move_box(data_a)]))


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		if y1 > y2:
			print(y1 - y2)
		else:
			print(y2 - y1)
	elif y1 == y2:
		if x1 > x2:
			print(x1 - x2)
		else:
			print(x2 - x1)
	else:
		if x1 > x2:
			vyc = x1 - x2
		else:
			vyc = x2 - x1
		if y1 > y2:
			d = y1 - y2
		else:
			d = y2 - y1
		print(vyc + d + 2)


import sys, collections, math, itertools
INF = sys.maxsize

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	(x1, y1, x2, y2) = get_ints()
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	(x, y) = (abs(a - c), abs(b - d))
	if x == 0 or y == 0:
		print(max(x, y))
	else:
		print(x + y + 2)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	(p, q) = (abs(x2 - x1), abs(y2 - y1))
	m = 0
	if p == 0 and q != 0:
		m = q
	if p != 0 and q == 0:
		m = p
	if p != 0 and q != 0:
		m = p + q + 2
	print(m)


t = int(input())
q = []
for i in range(t):
	l = list(input().split())
	x1 = int(l[0])
	y1 = int(l[1])
	x2 = int(l[2])
	y2 = int(l[3])
	dif_x = abs(x2 - x1)
	dif_y = abs(y2 - y1)
	if dif_x > 0 and dif_y > 0:
		sec = dif_x + dif_y + 2
	else:
		sec = dif_y + dif_x
	q.append(sec)
for i in q:
	print(i)


t = int(input())
while t > 0:
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		time = abs(y1 - y2)
	elif y1 == y2:
		time = abs(x1 - x2)
	else:
		time = abs(x1 - x2) + abs(y1 - y2) + 2
	print(time)
	t = t - 1


import sys
import math

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	(x1, y1, x2, y2) = rinput()
	cost = abs(x2 - x1) + abs(y2 - y1)
	if x1 == x2 and y1 == y2:
		print(0)
	elif x1 == x2 or y1 == y2:
		print(cost)
	else:
		print(cost + 2)


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	print(abs(a - c) + abs(b - d) + (a != c and b != d) * 2)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	(x1, y1, x2, y2) = inm()
	y = abs(y1 - y2)
	x = abs(x1 - x2)
	ans = x + y + (2 if x > 0 and y > 0 else 0)
	print(ans)


for t__ in range(int(input())):
	a = list(map(int, input().split()))
	print(abs(a[0] - a[2]) + abs(a[1] - a[3]) + (a[0] != a[2] and a[1] != a[3]) * 2)


import math
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 - x2 != 0 and y1 - y2 != 0:
		m = 2 + abs(x2 - x1) + abs(y2 - y1)
	else:
		m = abs(x2 - x1) + abs(y2 - y1)
	print(m)


l = []
for _ in range(int(input())):
	(x1, x2, y1, y2) = map(int, input().split())
	if x1 == y1 or x2 == y2:
		l.append(abs(x1 - y1) + abs(y2 - x2))
	else:
		l.append(abs(x1 - y1) + abs(x2 - y2) + 2)
for i in l:
	print(i)


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	count = 0
	if a - c == 0 or b - d == 0:
		print(abs(a - c) + abs(b - d))
	else:
		if a - c != 0:
			count += abs(a - c) + 1
		if b - d != 0:
			count += abs(b - d) + 1
		print(count)


for i in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	q = abs(x1 - x2) + abs(y1 - y2)
	print(q if x1 == x2 or y1 == y2 else q + 2)


t = int(input())
for h in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = 0
	if x1 == x2 or y1 == y2:
		ans += abs(x1 - x2)
		ans += abs(y1 - y2)
		print(ans)
	else:
		ans += abs(x1 - x2)
		ans += abs(y1 - y2)
		ans += 2
		print(ans)


for _ in ' ' * int(input()):
	(x, y, x1, y1) = map(int, input().split())
	if x == x1 and y1 == y:
		print(0)
	elif x == x1:
		print(abs(y - y1))
	elif y == y1:
		print(abs(x - x1))
	else:
		print(abs(x - x1) + abs(y - y1) + 2)


t = int(input())
res = list()
for i in range(0, t):
	(x1, y1, x2, y2) = map(int, input().split())
	tr = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		tr += 2
	res.append(tr)
for a in res:
	print(a)


import math
o = int(input())
for i in range(o):
	s = input()
	l = s.split()
	f1 = math.fabs(int(l[0]) - int(l[2]))
	f2 = math.fabs(int(l[1]) - int(l[3]))
	if int(l[0]) != int(l[2]) and int(l[1]) != int(l[3]):
		print(int(2 + f1 + f2))
	else:
		print(int(f1 + f2))


for _ in range(int(input())):
	(p, q, r, k) = [int(x) for x in input().split()]
	if p == r or q == k:
		print(abs(p - r) + abs(q - k))
	else:
		print(abs(p - r) + abs(q - k) + 2)


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	print(abs(a - c) + abs(b - d) + 2 * (a - c != 0) * (b - d != 0))


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	if y == 0:
		return 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

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

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	(x1, y1, x2, y2) = read()
	if x1 - x2 == 0:
		print(abs(y2 - y1))
		return
	if y1 - y2 == 0:
		print(abs(x2 - x1))
		return
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


t = int(input())
while t > 0:
	s = input()
	ar = map(lambda x: int(x), s.split(' '))
	a = list(ar)
	x1 = a[0]
	y1 = a[1]
	x2 = a[2]
	y2 = a[3]
	if x1 == x2:
		print(abs(y2 - y1))
	elif y2 == y1:
		print(abs(x2 - x1))
	else:
		delx = abs(x2 - x1)
		dely = abs(y2 - y1)
		print(2 + delx + dely)
	t = t - 1


PI = 3.141592653589793
INF = 999999999
MOD = 1000000007

def add(x, y):
	return (x + y) % MOD

def sub(x, y):
	return (x - y + MOD) % MOD

def mul(x, y):
	return x * y % MOD

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

def ii():
	return int(input())

def li():
	return [int(i) for i in input().split()]

def ls():
	return [i for i in input().split()]
for t in range(ii()):
	t += 1
	(x1, y1, x2, y2) = li()
	if x1 == x2 or y1 == y2:
		print(max(abs(x1 - x2), abs(y1 - y2)))
	else:
		print(2 + abs(x1 - x2) + abs(y1 - y2))


t = int(input())
for z in range(t):
	c = list(map(int, input().split()))
	d1 = abs(c[0] - c[2])
	d2 = abs(c[1] - c[3])
	if d1 > 0 and d2 > 0:
		print(d1 + d2 + 2)
	else:
		print(d1 + d2)


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	ans = 2
	if abs(x1 - x2) == 0 or abs(y1 - y2) == 0:
		ans -= 2
	ans += abs(x1 - x2)
	ans += abs(y1 - y2)
	print(ans)


n = int(input())
for _ in range(n):
	(x1, y1, x2, y2) = map(int, input().split())
	one = 0 if x1 == x2 or y1 == y2 else 2
	print(abs(x1 - x2) + abs(y1 - y2) + one)


for o in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	s = abs(a - c) + abs(b - d)
	if a != c and b != d:
		s = s + 2
	print(s)


for i in range(int(input())):
	(x, y, d, s) = map(int, input().split())
	if x == d or y == s:
		print(abs(x - d) + abs(y - s))
	else:
		print(abs(x - d) + abs(y - s) + 2)


n = int(input())
for _ in range(n):
	(x1, y1, x2, y2) = map(int, input().split())
	x = min(abs(x1 - x2), abs(y1 - y2)) * 2 + 2 if min(abs(x1 - x2), abs(y1 - y2)) * 2 != 0 else 0
	print(x + max(abs(x1 - x2), abs(y1 - y2)) - min(abs(x1 - x2), abs(y1 - y2)))


for x in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	dif = abs(a - c) + abs(b - d)
	if a != c and b != d:
		print(dif + 2)
	else:
		print(dif)


import sys
input = sys.stdin.buffer.readline

def solution():
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
t = int(input())
for _ in range(t):
	solution()


t = int(input())
for _ in range(t):
	arr = list(map(int, input().split(' ')))
	ans = abs(arr[0] - arr[2]) + abs(arr[1] - arr[3])
	if arr[0] - arr[2] and arr[1] - arr[3]:
		ans += 2
	print(ans)


numberOfTestCase = int(input())
for i in range(numberOfTestCase):
	cords = [int(x) for x in input().split()]
	dXcords = abs(cords[0] - cords[2])
	dYcords = abs(cords[1] - cords[3])
	totalDifference = dYcords + dXcords
	if dXcords == 0 or dYcords == 0:
		print(totalDifference)
	else:
		totalDifference = totalDifference + 2
		print(totalDifference)


import math
t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	x1 = a[0]
	y1 = a[1]
	x2 = a[2]
	y2 = a[3]
	delta_x = math.fabs(x2 - x1)
	delta_y = math.fabs(y2 - y1)
	if delta_x != 0 and delta_y != 0:
		time = delta_x + delta_y + 2
	else:
		time = delta_x + delta_y
	print(int(time))


I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(a, b, c, d) = I()
	ans = abs(a - c) + abs(b - d)
	if a != c and b != d:
		ans += 2
	print(ans)


import sys, os, io
I = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for tc in range(1, 1 + int(I())):
	(a, b, c, d) = map(int, I().rstrip().split())
	a = abs(a - c)
	b = abs(b - d)
	if a > 0 and b > 0:
		a += 2
	print(a + b)


tests = int(input())
for test in range(tests):
	(x1, y1, x2, y2) = map(int, input().split())
	d = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		d += 2
	print(d)


from collections import Counter
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	q = abs(x1 - x2)
	w = abs(y1 - y2)
	e = q + w
	if x1 == x2 or y1 == y2:
		print(e)
	else:
		print(e + 2)


for i in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	print(abs(x2 - x1) + abs(y2 - y1) + 2 * (x1 != x2) * (y2 != y1))


def box_is_pull(x1, y1, x2, y2):
	if x1 == x2:
		return abs(y2 - y1)
	elif y1 == y2:
		return abs(x2 - x1)
	else:
		return abs(x1 - x2) + abs(y1 - y2) + 2
for x in range(int(input())):
	(x1, y1, x2, y2) = [*map(int, input().split(' '))]
	print(box_is_pull(x1, y1, x2, y2))


def move_y(y1, y2):
	t_y = 0
	if y1 < y2:
		t_y += y2 - y1
	else:
		t_y += y1 - y2
	if t_y < 0:
		t_y *= -1
	return t_y
	print(t_y)

def move_x(x1, x2, y1, y2):
	t_x = 0
	if x1 < x2:
		t_x += x2 - x1
	else:
		t_x += x1 - x2
	if t_x < 0:
		t_x *= -1
	if y1 != y2:
		t1 = move_y(y1, y2)
		return t_x + t1 + 2
	else:
		return t_x
x = int(input())
for i in range(x):
	(x1, y1, x2, y2) = map(int, input().split())
	t = 0
	if x1 != x2:
		t = move_x(x1, x2, y1, y2)
	elif y1 != y2:
		t = move_y(y1, y2)
	print(t)


import os
import sys
from math import *
from collections import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(x1, y1, x2, y2) = value()
	ans = abs(x2 - x1) + abs(y2 - y1)
	if y1 != y2 and x1 != x2:
		ans += 2
	print(ans)


n_of_set = int(input())
for i in range(n_of_set):
	in_str = input()
	in_str = in_str.split(' ')
	x1 = int(in_str[0])
	y1 = int(in_str[1])
	x2 = int(in_str[2])
	y2 = int(in_str[3])
	answer = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		answer += 2
	print(answer)


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	(a, b, c, d) = MI()
	x = abs(a - c)
	y = abs(b - d)
	if 0 in [x, y]:
		ans = max(x, y)
	else:
		ans = x + y + 2
	print(ans)


import sys
import random
from typing import NamedTuple
input = sys.stdin.readline
T = int(input())
for t in range(T):
	(x1, y1, x2, y2) = map(int, input().split())
	time = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		time += 2
	print(time)


t = int(input())
for tt in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	time = abs(x1 - x2) + abs(y1 - y2)
	if x1 == x2 or y1 == y2:
		print(time)
	else:
		time += 2
		print(time)


T = int(input())
for i in range(T):
	A = list(map(int, input().split()))
	if A[0] == A[2]:
		print(abs(A[1] - A[3]))
	elif A[1] == A[3]:
		print(abs(A[0] - A[2]))
	else:
		print(abs(A[0] - A[2]) + abs(A[1] - A[3]) + 2)


from sys import stdin, stdout
input = stdin.readline
from collections import defaultdict as dd
import math

def geti():
	return map(int, input().strip().split())

def getl():
	return list(map(int, input().strip().split()))

def gets():
	return input()

def geta():
	return int(input())

def print_s(s):
	stdout.write(s + '\n')

def solve():
	for _ in range(geta()):
		(x1, y1, x2, y2) = geti()
		diff_x = abs(x2 - x1)
		diff_y = abs(y2 - y1)
		if diff_x * diff_y == 0:
			print(diff_x + diff_y)
		else:
			print(diff_x + diff_y + 2)
solve()


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	dx = abs(x2 - x1)
	dy = abs(y2 - y1)
	if dx == 0:
		print(dy)
		continue
	if dy == 0:
		print(dx)
		continue
	print(dx + dy + 2)


for _ in range(int(input())):
	(x, y, z, k) = map(int, input().split())
	if x == z or y == k:
		print(abs(x - z) + abs(y - k))
	else:
		print(abs(x - z) + abs(y - k) + 2)


for i in range(int(input())):
	answer = 0
	(a, b, c, d) = map(int, input().split(' '))
	if a - c != 0 and b - d != 0:
		answer = 2
	if a - c != 0:
		answer += abs(a - c)
	if b - d != 0:
		answer += abs(b - d)
	print(answer)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var, end='\n'):
	sys.stdout.write(str(var) + end)

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(x1, y1, x2, y2) = sp()
	(t1, t2) = (abs(x1 - x2), abs(y1 - y2))
	if t1 == 0 or t2 == 0:
		out(max(t1, t2))
		continue
	out(t1 + t2 + 2)


from collections import defaultdict
import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


t = int(input())
for tc in range(t):
	line = input().split()
	(x1, y1, x2, y2) = (int(line[0]), int(line[1]), int(line[2]), int(line[3]))
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		ans = abs(x1 - x2) + (2 + abs(y1 - y2))
		print(ans)


import sys, os
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 998244353

def main():
	ans_ = []
	for _ in range(int(input())):
		(x1, y1, x2, y2) = read()
		ans = abs(x1 - x2) + abs(y2 - y1)
		if not (x2 == x1 or y2 == y1):
			ans += 2
		ans_.append(str(ans))
	print('\n'.join(ans_))
main()


from sys import stdin
input = stdin.readline

def A():
	t = int(input())
	for _ in range(t):
		(x1, y1, x2, y2) = map(int, input().split())
		if x2 == x1:
			print(abs(y2 - y1))
		elif y1 == y2:
			print(abs(x2 - x1))
		else:
			print(abs(x2 - x1) + abs(y2 - y1) + 2)

def B():
	t = int(input())
	for _ in range(t):
		print()

def C():
	t = int(input())
	for _ in range(t):
		print()

def D():
	t = int(input())
	for _ in range(t):
		print()
A()


t = int(input())
for case in range(t):
	(start_x, start_y, end_x, end_y) = list(map(int, input().split()))
	diff_x = abs(end_x - start_x)
	diff_y = abs(end_y - start_y)
	if diff_x == 0:
		result = diff_y
	elif diff_y == 0:
		result = diff_x
	else:
		result = diff_x + diff_y + 2
	print(result)


t = int(input())
for testCase in range(t):
	a = [int(e) for e in input().split()]
	if a[0] == a[2] or a[1] == a[3]:
		print('%s' % str(abs(a[2] - a[0]) + abs(a[3] - a[1])))
	else:
		print('%s' % str(abs(a[2] - a[0]) + abs(a[3] - a[1]) + 2))


for tc in [0] * int(input()):
	[x1, y1, x2, y2] = list(map(int, input().split(' ')))
	t = 0
	if x1 != x2 and y1 == y2:
		t = abs(x1 - x2)
		print(t)
	elif x1 == x2 and y1 != y2:
		t = abs(y1 - y2)
		print(t)
	elif x1 == x2 and y1 == y2:
		print(0)
	else:
		t = abs(x2 - x1)
		t += 2
		t += abs(y2 - y1)
		print(t)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	x = abs(a - c)
	if b == d:
		print(x)
	elif a == c:
		print(abs(b - d))
	else:
		print(x + 2 + abs(b - d))


for _ in range(int(input())):
	(x, y, a, b) = map(int, input().split())
	move = abs(x - a) + abs(y - b)
	if abs(x - a) > 0 and abs(y - b) > 0:
		move += 2
	print(move)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	x = abs(x2 - x1)
	y = abs(y2 - y1)
	ans = 0
	if x == 0:
		ans = y
	elif y == 0:
		ans = x
	else:
		ans = x + y + 2
	print(ans)


for i in range(int(input())):
	l = list(map(int, input().split()))
	if abs(l[0] - l[2]) == 0 or abs(l[1] - l[3]) == 0:
		print(abs(l[0] - l[2]) + abs(l[1] - l[3]))
	else:
		print(abs(l[0] - l[2]) + abs(l[1] - l[3]) + 2)


for test in range(int(input())):
	[x1, y1, x2, y2] = list(map(int, input().split(' ')))
	x = abs(x1 - x2)
	y = abs(y1 - y2)
	if x == 0 and y == 0:
		print(0)
	elif x == 0:
		print(y)
	elif y == 0:
		print(x)
	else:
		print(x + y + 2)


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		print(abs(y2 - y1) + abs(x2 - x1))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


from math import *
import sys
from sys import stdin
from sys import stdout
for __ in range(int(input())):
	(x, y, a, b) = map(int, input().split())
	if x == a or y == b:
		print(abs(a - x) + abs(b - y))
	else:
		print(abs(a - x) + 2 + abs(b - y))


n = int(input())
for _ in range(n):
	s = list(input().split(' '))
	x = sorted([int(elem) for elem in s[::2]])
	y = sorted([int(elem) for elem in s[1::2]])
	print([y[1] - y[0], x[1] - x[0], y[1] - y[0] + x[1] - x[0] + 2][int(x[0] != x[1]) + int(x[0] != x[1] and y[0] != y[1])])


def readis():
	return map(int, input().strip().split())
T = int(input())
while T:
	T -= 1
	(x1, y1, x2, y2) = readis()
	print(abs(y2 - y1) + abs(x2 - x1) + 2 * int(y2 != y1 and x2 != x1))


t = int(input())
arr_i = []
for i in range(t):
	arr_i.append(input())
for a in arr_i:
	(q, w, e, r) = map(int, a.split())
	if q == e or w == r:
		print(abs(q - e) + abs(w - r))
	else:
		print(abs(q - e) + abs(w - r) + abs(2))


cases = int(input())
resultados = list()
for n in range(cases):
	lista = input()
	lista = lista.split(' ')
	lista = list(lista)
	(x1, y1, x2, y2) = (int(lista[0]), int(lista[1]), int(lista[2]), int(lista[3]))
	if x1 == x2:
		resultados.append(abs(y2 - y1))
	elif y1 == y2:
		resultados.append(abs(x2 - x1))
	else:
		resultados.append(abs(x2 - x1) + abs(y2 - y1) + 2)
for n in range(len(resultados)):
	print(resultados[n])


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(x1, y1, x2, y2) = In()
		t = abs(x2 - x1)
		z = abs(y2 - y1)
		ans = 0
		if t > 0 and z == 0:
			ans = t
		elif t == 0 and z > 0:
			ans = z
		elif t > 0 and z > 0:
			ans = t + 2
			ans += z
		print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


n = int(input())
for i in range(n):
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	ans = 0
	if x1 != x2 and y1 != y2:
		ans += 2
	ans += max(x1, x2) - min(x1, x2) + max(y1, y2) - min(y1, y2)
	print(ans)


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	(e, f) = (abs(a - c), abs(b - d))
	if e and f:
		print(e + f + 2)
	else:
		print(e + f)


n = int(input())
for i in range(n):
	z = list(map(int, input().split()))
	mh = abs(z[0] - z[2]) + abs(z[1] - z[3])
	if not (z[0] == z[2] or z[1] == z[3]):
		mh += 2
	print(mh)


for _ in [0] * int(input()):
	(a, b, c, d) = map(int, input().split())
	if a == c:
		print(abs(b - d))
	elif b == d:
		print(abs(a - c))
	else:
		print(abs(a - c) + abs(b - d) + 2)


import sys
from collections import defaultdict as dc
import math
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	f = 0
	if x1 != x2 and y1 != y2:
		f = 1
	p = abs(x1 - x2) + abs(y1 - y2)
	if f:
		print(p + 2)
	else:
		print(p)


inp = lambda : int(input())
strl = lambda : list(input().strip())
seq = lambda : list(map(int, input().strip().split()))

def results(arr):
	(x1, y1, x2, y2) = (arr[0], arr[1], arr[2], arr[3])
	if x1 == x2 or y1 == y2:
		if x1 == x2:
			return abs(y1 - y2)
		elif y1 == y2:
			return abs(x1 - x2)
	else:
		return 2 + abs(x1 - x2) + abs(y1 - y2)

def main():
	t = inp()
	for _ in range(t):
		a = seq()
		result = results(a)
		print(result)
main()


t = int(input())
while t > 0:
	t -= 1
	(x1, x2, x3, x4) = map(int, input().split())
	r = abs(x3 - x1) + abs(x4 - x2)
	if x3 == x1 or x4 == x2:
		print(r)
		continue
	print(r + 2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	for _ in range(int(input())):
		(x1, y1, x2, y2) = [int(x) for x in input().split()]
		if x1 == x2 and y1 == y2:
			print(0)
		elif x1 == x2:
			print(abs(y1 - y2))
		elif y1 == y2:
			print(abs(x1 - x2))
		else:
			print(abs(x1 - x2) + abs(y1 - y2) + 2)
main()


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	(x1, y1, x2, y2) = map(int, inputi().split())
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x2 - x1))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


def box_pull(x1, y1, x2, y2):
	if x1 == x2:
		return abs(y1 - y2)
	elif y1 == y2:
		return abs(x1 - x2)
	else:
		return abs(x1 - x2) + abs(y1 - y2) + 2
t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	print(box_pull(x1, y1, x2, y2))


t = int(input())
data = []
for i in range(t):
	cordinate = [int(j) for j in input().split()]
	dats = []
	if cordinate[0] == cordinate[2] or cordinate[1] == cordinate[3]:
		data.append(abs(cordinate[0] - cordinate[2]) + abs(cordinate[1] - cordinate[3]))
	else:
		data.append(abs(cordinate[0] - cordinate[2]) + abs(cordinate[1] - cordinate[3]) + 2)
for i in range(t):
	print(data[i])


def calc(x1, y1, x2, y2):
	if abs(x1 - x2) + abs(y1 - y2) == 1:
		return 1
	if abs(x1 - x2) + abs(y1 - y2) == 0:
		return 0
	if x1 == x2:
		return abs(y1 - y2)
	if y1 == y2:
		return abs(x1 - x2)
	else:
		ans = abs(y1 - y2)
		ans += 2
		ans += max(abs(x2 - x1) - 1, 0)
		return ans + 1
t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	print(calc(x1, y1, x2, y2))


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = abs(x1 - x2) + abs(y1 - y2) + 2
	if x1 == x2 or y1 == y2:
		ans -= 2
	print(ans)


n = int(input())
while n:
	(x1, y1, x2, y2) = input().split(' ')
	x1 = int(x1)
	x2 = int(x2)
	y1 = int(y1)
	y2 = int(y2)
	if x1 == x2:
		if y1 > y2:
			print(y1 - y2)
		else:
			print(y2 - y1)
	elif y1 == y2:
		if x1 > x2:
			print(x1 - x2)
		else:
			print(x2 - x1)
	elif x1 == x2 and y1 == y2:
		print(0)
	elif x1 < x2 and y1 < y2:
		print(x2 - x1 + (y2 - y1) + 2)
	elif x1 < x2 and y2 < y1:
		print(x2 - x1 + (y1 - y2) + 2)
	elif x1 > x2 and y1 < y2:
		print(x1 - x2 + (y2 - y1) + 2)
	else:
		print(x1 - x2 + (y1 - y2) + 2)
	n = n - 1


import io
import os
import math
cin = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
MAX = 1
MIN = -1

def get_input():
	return cin().split()

def get_int_input():
	return list(map(int, get_input()))

def C1428A(x1, y1, x2, y2):
	xdiff = abs(x1 - x2)
	ydiff = abs(y1 - y2)
	ans = 0
	if xdiff and ydiff:
		ans += 2
	ans += xdiff
	ans += ydiff
	return ans

def main():
	(T,) = get_int_input()
	for _ in range(T):
		(x1, y1, x2, y2) = get_int_input()
		print(C1428A(x1, y1, x2, y2))
main()


for _ in range(int(input())):
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		ans += 2
	print(ans)


import math
from collections import Counter, defaultdict, deque

def f(p):
	(x1, y1, x2, y2) = p
	if x1 == x2:
		return abs(y2 - y1)
	elif y1 == y2:
		return abs(x1 - x2)
	return 2 + abs(x2 - x1) + abs(y2 - y1)
t = int(input())
result = []
for i in range(t):
	p = list(map(int, input().split()))
	result.append(f(p))
for i in range(t):
	print(result[i])


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	x1 = l[0]
	y1 = l[1]
	x2 = l[2]
	y2 = l[3]
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	if dx == 0 or dy == 0:
		print(dx + dy)
	if dx != 0 and dy != 0:
		ds = abs(dx - dy)
		dd = min(dx, dy)
		t = ds + 2 * dd + 2
		print(t)


T = int(input())
for t in range(T):
	(x1, y1, x2, y2) = [int(i) for i in input().split(' ')]
	total = 0
	total += abs(x2 - x1)
	if total == 0:
		print(abs(y2 - y1))
		continue
	total += abs(y2 - y1)
	if abs(y2 - y1) != 0:
		total += 2
	print(total)


import sys
import os
from math import sqrt, log, log2, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def permute(nums):

	def fun(arr, nums, cur, v):
		if len(cur) == len(nums):
			arr.append(cur.copy())
		i = 0
		while i < len(nums):
			if v[i]:
				i += 1
				continue
			else:
				cur.append(nums[i])
				v[i] = 1
				fun(arr, nums, cur, v)
				cur.pop()
				v[i] = 0
				i += 1
		return arr
	res = []
	nums.sort()
	v = [0] * len(nums)
	return fun(res, nums, [], v)

def subsets(res, index, arr, cur):
	res.append(cur.copy())
	for i in range(index, len(arr)):
		cur.append(arr[i])
		subsets(res, i + 1, arr, cur)
		cur.pop()
	return res

def sieve(N):
	root = int(sqrt(N))
	primes = [1] * (N + 1)
	(primes[0], primes[1]) = (0, 0)
	for i in range(2, root + 1):
		if primes[i]:
			for j in range(i * i, N + 1, i):
				primes[j] = 0
	return primes

def bs(arr, l, r, x):
	if x < arr[0] or x > arr[len(arr) - 1]:
		return -1
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def solve():
	ans = 0
	(x1, y1, x2, y2) = mint()
	if x1 == x2:
		print(abs(y1 - y2))
		return
	if y1 == y2:
		print(abs(x1 - x2))
		return
	ans += abs(x1 - x2) + abs(y1 - y2)
	ans += 2
	print(ans)
for _ in range(iinp()):
	solve()


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
t = int(input())
for t1 in range(t):
	(x1, y1, x2, y2) = [int(n1) for n1 in input().split()]
	ans = 0
	if abs(x1 - x2) >= abs(y1 - y2):
		ans = abs(x1 - x2)
		if abs(y1 - y2) > 0:
			ans = ans + abs(y1 - y2) + 2
	else:
		ans = abs(y1 - y2)
		if abs(x1 - x2) > 0:
			ans = ans + abs(x1 - x2) + 2
	print(ans)


def solve(x1, y1, x2, y2):
	if x1 == x2 or y1 == y2:
		return abs(x1 - x2) + abs(y1 - y2)
	return abs(x1 - x2) + abs(y1 - y2) + 2
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	print(solve(x1, y1, x2, y2))


import sys
t = int(input())
while t > 0:
	t -= 1
	input = sys.stdin.readline()
	(x1, y1, x2, y2) = map(int, input.split())
	if abs(x1 - x2) + abs(y1 - y2) == 0:
		print(0)
	elif abs(x1 - x2) == 0 or abs(y1 - y2) == 0:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(2 + abs(x1 - x2) + abs(y1 - y2))


t = int(input())
for i in range(t):
	a = [int(i) for i in input().split()]
	if a[0] == a[2]:
		print(abs(a[1] - a[3]))
	elif a[1] == a[3]:
		print(abs(a[0] - a[2]))
	else:
		c = 2
		c += abs(a[0] - a[2])
		c += abs(a[1] - a[3])
		print(c)


for _ in range(int(input())):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	print(abs(x1 - x2) + abs(y1 - y2) + [2, 0][x1 == x2 or y1 == y2])


import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
	t = int(input())
	for _ in range(t):
		(x1, y1, x2, y2) = map(int, input().split())
		diff_x = abs(x1 - x2)
		diff_y = abs(y1 - y2)
		if not diff_x and diff_y:
			print(diff_y)
		elif diff_x and (not diff_y):
			print(diff_x)
		elif not diff_x and (not diff_y):
			print(0)
		else:
			print(diff_x + diff_y + 2)
resolve()


t = int(input())
while t:
	(a, b, c, d) = map(int, input().split())
	if b == d:
		print(abs(c - a))
	elif a == c:
		print(abs(d - b))
	else:
		print(abs(c - a) + 1 + (abs(b - d) + 1))
	t -= 1


def testcase():
	(x1, y1, x2, y2) = map(int, input().split())
	x = abs(x1 - x2)
	y = abs(y1 - y2)
	ans = x + y
	if x > 0 and y > 0:
		ans += 2
	print(ans)
	return
t = int(input())
for _ in range(t):
	testcase()


from functools import reduce
import collections
import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(delimiter=' '):
		return input().split(delimiter)

	@staticmethod
	def list_int(delimiter=' '):
		return list(map(int, input().split(delimiter)))

def main():
	t = Read.int()
	for _ in range(t):
		(x1, y1, x2, y2) = Read.list_int()
		if x2 == x1 and y1 == y2:
			print(0)
		elif x2 == x1 or y1 == y2:
			print(abs(x2 - x1) + abs(y2 - y1))
		else:
			print(abs(x2 - x1) + 2 + abs(y2 - y1))
main()


def solve(x1, y1, x2, y2):
	x = abs(x1 - x2)
	y = abs(y1 - y2)
	if x == 0 and y == 0:
		return 0
	if x == 0:
		return y
	if y == 0:
		return x
	return x + y + 2
t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	print(solve(x1, y1, x2, y2))


def main():
	for _ in range(int(input())):
		(x1, y1, x2, y2) = map(int, input().split())
		if x1 == x2 or y1 == y2:
			print(max(abs(x2 - x1), abs(y2 - y1)))
		else:
			print(2 + (abs(x2 - x1) + abs(y2 - y1)))
main()


for _ in range(int(input())):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	t = 0
	if x1 != x2:
		t = abs(x2 - x1)
	if y1 != y2:
		t += abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		t += 2
	print(t)


n = int(input())
for _ in range(n):
	line = input()
	(x1, y1, x2, y2) = map(int, line.split(' '))
	(dx, dy) = (abs(x1 - x2), abs(y1 - y2))
	ans = dx + dy + 2 if dx > 0 and dy > 0 else dx + dy
	print(ans)


n = input()
for i in range(int(n)):
	s = 0
	(x1, y1, x2, y2) = [int(x) for x in input('').split()]
	if x1 == x2 or y1 == y2:
		s = abs(x2 - x1) + abs(y2 - y1)
	else:
		s = abs(x2 - x1) + abs(y2 - y1) + 2
	print(s)


import os
from sys import stdin, stdout

def solve(tc):
	(x1, y1, x2, y2) = map(int, stdin.readline().split())
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
tcs = 1
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


t = int(input())
while t > 0:
	(a, b, c, d) = map(int, input().split())
	if a == c or b == d:
		print(abs(a - c) + abs(b - d))
	else:
		print(abs(a - c) + abs(b - d) + 2)
	t -= 1


t = int(input())
for _ in range(t):
	(r1, c1, r2, c2) = map(int, input().split())
	if r1 == r2:
		print(abs(c1 - c2))
	elif c1 == c2:
		print(abs(r1 - r2))
	else:
		print(abs(r1 - r2) + 2 + abs(c1 - c2))


for _ in range(int(input())):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	change = 0
	if x1 != x2 and y1 != y2:
		change = 1
	disp = 0
	disp += abs(x1 - x2)
	disp += abs(y1 - y2)
	disp += 2 * change
	print(disp)


for _ in range(int(input())):
	(a, b, x, y) = map(int, input().split())
	ans = 0
	if not (y - b == 0 or x - a == 0):
		ans += 2
	ans += abs(y - b) + abs(x - a)
	print(ans)


for _ in range(int(input())):
	a = input().split()
	x1 = int(a[0])
	y1 = int(a[1])
	x2 = int(a[2])
	y2 = int(a[3])
	res = 0
	if x1 != x2 and y1 != y2:
		res += 2
	if x2 > x1:
		x = x2 - x1
	else:
		x = x1 - x2
	if y2 > y1:
		y = y2 - y1
	else:
		y = y1 - y2
	print(res + y + x)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(x, y, a, b) = map(int, input().split())
	if x == a or y == b:
		print(max(abs(x - a), abs(y - b)))
	else:
		print(abs(x - a) + abs(y - b) + 2)


for i in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	count = 0
	if x1 > x2:
		d1 = x1 - x2
	else:
		d1 = x2 - x1
	if y1 > y2:
		d2 = y1 - y2
	else:
		d2 = y2 - y1
	if d2 != 0 and d1 != 0:
		count = d1 + 2 + d2
	else:
		count = d1 + d2
	print(count)


t = int(input())
while t:
	t -= 1
	(a, b, x, y) = map(int, input().split())
	if a != x and b != y:
		ans = abs(a - x) + abs(b - y) + 2
	elif a == x:
		ans = abs(b - y)
	else:
		ans = abs(a - x)
	print(ans)


import math, sys, os
from collections import defaultdict, deque, OrderedDict, Counter
import bisect as bi
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def minp():
	return map(int, sys.stdin.readline().rstrip().split())

def linp():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def inp():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))

def BinarySearch(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def gcd(a, b):
	return math.gcd(a, b)

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def mulinverse(a):
	return pow(a, mod - 2, mod)
for _ in range(inp()):
	(x1, y1, x2, y2) = minp()
	if x1 - x2 == 0 or y1 - y2 == 0:
		print(abs(x1 - x2) + abs(y1 - y2))
		continue
	print(abs(x1 - x2) + abs(y1 - y2) + 2)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	j = abs(a - c)
	k = abs(b - d)
	s = min(j, k)
	if j > 0 and k > 0:
		print(j + k + 2)
	else:
		print(j + k)


import os

def main():
	test_cases = int(input())
	ans = [None] * test_cases
	for t in range(test_cases):
		(x_1, y_1, x_2, y_2) = tuple(map(int, input().split()))
		(inc_x, inc_y) = (abs(x_1 - x_2), abs(y_1 - y_2))
		corner = 2 if inc_x and inc_y else 0
		ans[t] = inc_x + inc_y + corner
	os.write(1, '\n'.join(map(str, ans)).encode())
main()


for _ in range(int(input())):
	(x_1, y_1, x_2, y_2) = list(map(int, input().split()))
	if x_1 == x_2:
		print(abs(y_2 - y_1))
	elif y_1 == y_2:
		print(abs(x_2 - x_1))
	else:
		print(abs(x_2 - x_1) + 3 + abs(y_2 - y_1) - 1)


t = int(input())
time = int()
for i in range(t):
	cords = list(map(int, input().split()))
	(x1, y1, x2, y2) = (cords[0], cords[1], cords[2], cords[3])
	(bx, by) = (1, 1)
	(rx, ry) = (bx + 1, by + 1)
	time = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		time += 2
	print(time)


exec(int(input()) * 'a,b,c,d=map(int,input().split());print((abs(a-c)+abs(b-d))+2*(a!=c and b!=d));')


from collections import *
from itertools import *
from bisect import *

def index(a, x):
	i = bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	raise ValueError

def find_lt(a, x):
	i = bisect_left(a, x)
	if i:
		return a[i - 1]
	raise ValueError

def find_le(a, x):
	i = bisect_right(a, x)
	if i:
		return a[i - 1]
	raise ValueError

def find_gt(a, x):
	i = bisect_right(a, x)
	if i != len(a):
		return a[i]
	raise ValueError

def find_ge(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return a[i]
	raise ValueError

def inp():
	return int(input())

def arrinp():
	return [int(x) for x in input().split()]

def main():
	t = inp()
	for _ in range(t):
		(x1, y1, x2, y2) = arrinp()
		ans = abs(x2 - x1) + abs(y2 - y1)
		if x2 != x1 and y2 != y1:
			ans += 2
		print(ans)
main()


import sys
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
input = sys.stdin.readline
getS = lambda : input().strip()
getN = lambda : int(input())
getList = lambda : list(map(int, input().split()))
getZList = lambda : [int(x) - 1 for x in input().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)

def solve():
	(a, b, x, y) = getList()
	if a == x:
		print(abs(b - y))
		return
	if b == y:
		print(abs(a - x))
		return
	print(abs(a - x) + abs(b - y) + 2)

def main():
	n = getN()
	for _ in range(n):
		solve()
	return
main()


t = int(input())
for f in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	a = abs(x1 - x2)
	b = abs(y1 - y2)
	c = min(a, b)
	d = max(a, b)
	if a == 0 or b == 0:
		print(max(a, b))
	else:
		print(c + d + 2)


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if b == d:
		print(abs(c - a))
		continue
	if a == c:
		print(abs(b - d))
		continue
	print(abs(c - a) + 2 + abs(b - d))


n = int(input())
ans = []
for i in range(n):
	x = [int(x) for x in input().split()]
	lenth = abs(x[0] - x[2]) + abs(x[1] - x[3])
	if x[0] == x[2] or x[1] == x[3]:
		ans.append(lenth)
	else:
		ans.append(lenth + 2)
for a in ans:
	print(a)


n = int(input())
for i in range(n):
	ans = 0
	(a1, b1, a2, b2) = map(int, input().split())
	if a1 == a2 and b1 == b2:
		print(ans)
		continue
	if a1 != a2 and b1 != b2:
		ans += 2
	ans += abs(a1 - a2)
	ans += abs(b1 - b2)
	print(ans)


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def get_input(a=str):
	return a(input())

def get_int_input():
	return get_input(int)

def get_input_arr(a):
	return list(map(a, input().split()))

def get_int_input_arr():
	return get_input_arr(int)

def solve():
	t = get_int_input()
	for _ in range(t):
		(x1, y1, x2, y2) = get_int_input_arr()
		if x1 == x2 or y1 == y2:
			cout << abs(x1 - x2) + abs(y1 - y2) << endl
		else:
			res = 0
			res += abs(x1 - x2)
			res += 2
			res += abs(y1 - y2)
			cout << res << endl

def main():
	solve()
main()


from sys import stdin
input = stdin.readline

def solve():
	(a, b, c, d) = map(int, input().split())
	dx = abs(c - a)
	dy = abs(d - b)
	if dx == 0 or dy == 0:
		print(dx + dy)
	else:
		print(dx + dy + 2)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(a, b, c, d) = list(map(int, input().split()))
	if a == c and b == d:
		print(0)
	elif a == c:
		print(abs(b - d))
	elif b == d:
		print(abs(a - c))
	else:
		ans = abs(a - c) + abs(b - d) + 2
		print(ans)


t = int(input())
for tc in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 == x2 or y1 == y2:
		print(f'{ans}')
	else:
		print(f'{ans + +2}')


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
from sys import stdin, stdout
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	answer = abs(x1 - x2)
	if y1 != y2 and answer != 0:
		answer += 2
	answer += abs(y1 - y2)
	print(answer)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split(' '))
	a = abs(y2 - y1)
	b = abs(x2 - x1)
	if a == 0 or b == 0:
		ans = max(a, b)
	else:
		ans = a + b + 2
	print(ans)


def Wabbit(x1, y1, x2, y2):
	x = min(abs(x2 - x1), abs(y2 - y1))
	y = max(abs(x2 - x1), abs(y2 - y1))
	if x == 0:
		return y
	else:
		return x + y + 2
for i in range(int(input())):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	print(Wabbit(x1, y1, x2, y2))


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *
from itertools import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	(x, y, x1, y1) = ma()
	if y == y1:
		print(abs(x - x1))
	elif x == x1:
		print(abs(y - y1))
	else:
		print(2 + abs(x - x1) + abs(y - y1))


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
from itertools import accumulate as ac
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	(a, b, x, y) = inp()
	if a == x and b != y:
		ans = abs(b - y)
	elif a != x and b == y:
		ans = abs(a - x)
	elif a == x and b == y:
		ans = 0
	else:
		ans = abs(a - x) + abs(b - y) + 2
	print(ans)


from math import *
t = int(input())
for i in range(0, t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(max(y1, y2) - min(y1, y2))
	elif y1 == y2:
		print(max(x1, x2) - min(x1, x2))
	else:
		print(max(x1, x2) - min(x1, x2) + max(y1, y2) - min(y1, y2) + 2)


t = int(input())
while t:
	a = input()
	(x1, y1, x2, y2) = [int(x) for x in a.split()]
	x = int(((x2 - x1) ** 2) ** 0.5)
	y = int(((y2 - y1) ** 2) ** 0.5)
	if x == 0 or y == 0:
		print(x + y)
	else:
		print(x + y + 2)
	t -= 1


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if a - c == 0 or b - d == 0:
		print(max(abs(a - c), abs(b - d)))
	else:
		print(abs(a - c) + abs(b - d) + 2)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
getcontext().prec = 25
from itertools import permutations
MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split(' '))
	ans = 2
	if x1 == x2 or y1 == y2:
		ans -= 2
	print(ans + abs(x1 - x2) + abs(y1 - y2))


for g in [*open(0)][1:]:
	(a, b, c, d) = map(int, g.split())
	print(abs(a - c) + abs(b - d) + 2 * (a != c and b != d))


t = int(input())
for i in range(t):
	l = input()
	L = l.split()
	for i in range(len(L)):
		L[i] = int(L[i])
	X1 = L[0]
	Y1 = L[1]
	X2 = L[2]
	Y2 = L[3]
	if X1 == X2:
		print(abs(Y2 - Y1))
	elif Y1 == Y2:
		print(abs(X2 - X1))
	else:
		print(abs(Y2 - Y1) + abs(X2 - X1) + 2)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, [item for item in input().split() if len(item)])
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		ans += 2
	print(ans)


t = int(input())
for i in range(t):
	s = input()
	s1 = s.split()
	x1 = int(s1[0])
	y1 = int(s1[1])
	x2 = int(s1[2])
	y2 = int(s1[3])
	if x1 == x2 or y1 == y2:
		print(abs(x2 - x1) + abs(y2 - y1))
	else:
		print(2 + abs(x2 - x1) + abs(y2 - y1))


try:
	t = int(input())
	while t != 0:
		(x1, y1, x2, y2) = map(int, input().split())
		if x1 == x2 or y1 == y2:
			print(abs(x2 - x1) + abs(y2 - y1))
		else:
			print(abs(x2 - x1) + abs(y2 - y1) + 2)
		t = t - 1
except EOFError:
	print(' ')


def process_test_case(i_t):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = 0
	if x1 == x2:
		ans = abs(y1 - y2)
	elif y1 == y2:
		ans = abs(x1 - x2)
	else:
		ans = abs(y1 - y2) + abs(x1 - x2) + 2
	print(ans)
	return None
n_tests = int(input())
for i_test in range(1, n_tests + 1):
	process_test_case(i_test)


import math
for i in range(int(input())):
	a = list(map(int, input().split()))
	(x1, y1, x2, y2) = a
	res = abs(x1 - x2) + abs(y1 - y2) + (x1 != x2 and y1 != y2) * 2
	print(res)


import sys
tests = int(sys.stdin.readline())
for i in range(tests):
	(x1, y1, x2, y2) = map(int, sys.stdin.readline().split())
	xdiff = abs(x2 - x1)
	ydiff = abs(y2 - y1)
	if xdiff == 0 or ydiff == 0:
		print(xdiff + ydiff)
	else:
		print(xdiff + ydiff + 2)


for _ in range(int(input())):
	(a, b, c, d) = [int(o) for o in input().split()]
	s = abs(c - a)
	k = abs(d - b)
	if s == 0 or k == 0:
		print(s + k)
	else:
		print(s + k + 2)


import sys
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))

def solve():
	(x1, y1, x2, y2) = read()
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(y1 - y2) + abs(x1 - x2) + 2)
for t in range(int(input())):
	solve()


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def ceil1(a, b):
	return (a + b - 1) // b

def solve():
	for _ in range(ii()):
		(x1, y1, x2, y2) = mi()
		ans = abs(y1 - y2) + abs(x1 - x2)
		if x1 == x2:
			print(ans)
			continue
		if y1 == y2:
			print(ans)
			continue
		print(ans + 2)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
solve()


t = int(input())
while t:
	t -= 1
	(x1, y1, x2, y2) = list(map(int, input().split()))
	if x2 - x1 == 0 or y2 - y1 == 0:
		dist = abs(y2 - y1) + abs(x2 - x1)
	else:
		dist = abs(y2 - y1) + abs(x2 - x1) + 2
	print(dist)


import sys
tc = int(sys.stdin.readline())
for _ in range(tc):
	(x1, y1, x2, y2) = map(int, sys.stdin.readline().split())
	if x1 == x2 and y1 != y2:
		print(abs(y2 - y1))
	elif x1 != x2 and y1 == y2:
		print(abs(x2 - x1))
	elif x1 == x2 and y1 == y2:
		print(0)
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


T = int(input())
for __ in range(T):
	(x1, y1, x2, y2) = map(int, input().split())
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	s = dx + dy + (2 if dx != 0 != dy else 0)
	print(s)


t = int(input())
for _ in range(t):
	a = [int(p) for p in input().split()]
	if a[0] == a[2]:
		if a[1] > a[3]:
			print(a[1] - a[3])
		else:
			print(a[3] - a[1])
	elif a[1] == a[3]:
		if a[0] > a[2]:
			print(a[0] - a[2])
		else:
			print(-1 * (a[0] - a[2]))
	else:
		c = 0
		if a[0] > a[2]:
			c += a[0] - a[2]
		else:
			c += -1 * (a[0] - a[2])
		if a[1] > a[3]:
			c += a[1] - a[3]
		else:
			c += -1 * (a[1] - a[3])
		print(c + 2)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = 10 ** 9 + 7
for t in range(int(data())):
	(x1, y1, x2, y2) = mdata()
	ans = abs(x2 - x1) + abs(y1 - y2)
	if abs(x2 - x1) > 0 and abs(y1 - y2) > 0:
		ans += 2
	out(ans)


def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split(' ')))
t = read_int()
for case_num in range(t):
	(x1, y1, x2, y2) = read_ints()
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


t = int(input())
for _ in range(t):
	x = input().strip().split()
	Wabbit = [int(j) for j in x[:2]]
	Box = [int(i) for i in x[2:]]
	Reach = 0
	if Wabbit[0] != Box[0] and Wabbit[1] != Box[1]:
		Reach += 2
	Reach += abs(Wabbit[0] - Box[0]) + abs(Wabbit[1] - Box[1])
	print(Reach)


import math
import sys
import itertools
import fractions
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
for t in wtf[1:]:
	(x1, y1, x2, y2) = map(int, t.split())
	dx = abs(x2 - x1)
	dy = abs(y2 - y1)
	d = dx + dy
	print(d if d <= 1 or dx == 0 or dy == 0 else d + 2)


try:
	x = int(input())
	for _ in range(x):
		a = list(map(int, input().split()))
		z = abs(a[0] - a[2]) + abs(a[1] - a[3])
		if abs(a[0] - a[2]) != 0 and abs(a[1] - a[3]) != 0:
			z = z + 2
		print(z)
except:
	pass


import sys
from collections import deque

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	(a, b, c, d) = mi()
	p = abs(a - c)
	q = abs(b - d)
	if min(p, q) == 0:
		print(max(p, q))
	else:
		print(p + q + 2)


exec(int(input()) * 'x1,y1,x2,y2=map(int,input().split());print((abs(x1-x2)+abs(y1-y2))+2*(x1!=x2 and y1!=y2));')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(y1 - y2) + abs(x1 - x2) + 2)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	(x1, y1, x2, y2) = mi()
	if x1 != x2 and y1 != y2:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
	else:
		print(abs(x1 - x2) + abs(y1 - y2))


from collections import defaultdict
import sys
import math
import random

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(x1, y1, x2, y2) = get_ints()
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
for _ in range(n):
	l = inlt()
	x1 = l[0]
	y1 = l[1]
	x2 = l[2]
	y2 = l[3]
	if x1 != x2 and y1 != y2:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)
	else:
		print(abs(x2 - x1) + abs(y2 - y1))


def time(x1, y1, x2, y2):
	x_dis = x2 - x1
	y_dis = y2 - y1
	if x_dis == 0:
		return abs(y2 - y1)
	elif y_dis == 0:
		return abs(x2 - x1)
	else:
		return 2 + abs(x2 - x1) + abs(y2 - y1)
test = int(input())
for i in range(test):
	(x1, y1, x2, y2) = map(int, input().split())
	print(time(x1, y1, x2, y2))


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().strip().split(' '))
	res = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		res = res + 2
	print(res)


import sys

def In():
	return sys.stdin.readline()

def Out(x):
	return sys.stdout.write(str(x) + '\n')

def solve(x1, y1, x2, y2):
	if x1 == x2:
		return abs(y2 - y1)
	if y1 == y2:
		return abs(x2 - x1)
	return abs(x2 - x1) + 2 + abs(y2 - y1)
t = int(In())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	Out(solve(x1, y1, x2, y2))


for _ in range(int(input())):
	(xl, yl, xr, yr) = map(int, input().split())
	if xl == xr or yl == yr:
		print(abs(xl - xr) + abs(yl - yr))
	else:
		print(abs(xl - xr) + abs(yl - yr) + 2)


for _ in range(int(input())):
	(x1, x2, y1, y2) = map(int, input().split())
	d1 = abs(x1 - y1)
	d2 = abs(x2 - y2)
	D1 = min(d1, d2)
	D2 = max(d1, d2)
	if D1 == 0:
		print(D2)
	else:
		print(D1 + D2 + 2)


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	(x1, y1, x2, y2) = list(map(int, readline().split()))
	if x1 == x2 or y1 == y2:
		Ans[qu] = abs(x1 - x2) + abs(y1 - y2)
	else:
		Ans[qu] = abs(x1 - x2) + abs(y1 - y2) + 2
print('\n'.join(map(str, Ans)))


import math
n = int(input())
for i in range(n):
	s = input().split(' ')
	a = abs(int(s[0]) - int(s[2])) + abs(int(s[1]) - int(s[3]))
	if s[0] != s[2] and s[1] != s[3]:
		a += 2
	print(a)


mod = 10 ** 9 + 7

def solve():
	(x1, y1, x2, y2) = map(int, input().split())
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		ans += 2
	print(ans)
t = 1
t = int(input())
while t > 0:
	solve()
	t -= 1


def main():
	(x1, y1, x2, y2) = map(int, input().split())
	time = 0
	if x1 != x2 and y1 != y2:
		time += 2
	time += abs(x1 - x2) + abs(y1 - y2)
	print(time)
t = int(input())
for i in range(t):
	main()


import math
teststring = '2\n1 2 2 2\n1 1 2 2\n'
online = 'Problem_A' not in __file__
(true, false) = (True, False)
if True:

	def spitout():
		for c in teststring.splitlines():
			yield c
	_ito = spitout()
	if not online:

		def input():
			return next(_ito)

	def build_enum(*a):
		built = dict()
		for (i, c) in enumerate(a):
			built[c] = i
		return lambda x: built[x]
T = int(input())
for ti in range(1, T + 1):
	[x1, y1, x2, y2] = map(int, input().split(' '))
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 == x2 or y1 == y2:
		print(ans)
	else:
		print(ans + 2)


import sys
import math
from collections import Counter
from collections import OrderedDict
from functools import reduce
sys.setrecursionlimit(10 ** 6)

def inputt():
	return sys.stdin.readline().strip()

def printt(n):
	sys.stdout.write(str(n) + '\n')

def listt():
	return [int(i) for i in inputt().split()]

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b // gcd(a, b)

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	a = abs(x2 - x1)
	b = abs(y2 - y1)
	if x1 == x2 or y1 == y2:
		print(a + b)
	else:
		print(a + b + 2)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(a, b, c, d) = list(map(int, input().split()))
		if c == a:
			yield abs(d - b)
		elif d == b:
			yield abs(c - a)
		else:
			yield (abs(c - a) + abs(d - b) + 2)
t = int(input())
ans = gift()
print(*ans, sep='\n')


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	(x1, y1, x2, y2) = zzz()
	if x1 == x2:
		print(abs(y1 - y2))
		continue
	if y1 == y2:
		print(abs(x1 - x2))
		continue
	print(abs(x1 - x2) + abs(y1 - y2) + 2)


num = int(input())
for i in range(num):
	a = list(map(int, input().split()))
	c = abs(a[2] - a[0])
	d = abs(a[3] - a[1])
	if c * d == 0:
		print(str(c + d))
	else:
		print(str(c + d + 2))


try:
	t = int(input())
	for i in range(t):
		l = list(map(int, input().split()))
		if l[0] == l[2] and l[1] == l[3]:
			ans = 0
		elif l[0] == l[2]:
			a = abs(l[1] - l[3])
			ans = a
		elif l[1] == l[3]:
			a = abs(l[0] - l[2])
			ans = a
		else:
			a = abs(l[1] - l[3])
			b = abs(l[0] - l[2])
			ans = a + b + 2
		print(ans)
except:
	pass


def rabbit(values):
	if values[1] == values[3]:
		return abs(values[0] - values[2])
	elif values[0] == values[2]:
		return abs(values[1] - values[3])
	else:
		return abs(values[0] - values[2]) + 2 + abs(values[1] - values[3])
t = int(input())
for i in range(t):
	values = list(map(int, input().split()))
	print(rabbit(values))


import math
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 != x2 and y1 != y2:
		p = abs(x1 - x2) + abs(y1 - y2) + 2
		print(p)
	else:
		p = abs(x1 - x2) + abs(y1 - y2)
		print(p)


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def valid(row, col, rows, cols, rcross, lcross):
	return rows[row] == 0 and cols[col] == 0 and (rcross[col + row] == 0) and (lcross[col - row] == 0)

def main():
	ans = ''
	for _ in range(ii()):
		(x1, y1, x2, y2) = mi()
		if x1 == x2:
			ans += str(abs(y2 - y1)) + '\n'
		elif y1 == y2:
			ans += str(abs(x2 - x1)) + '\n'
		else:
			ans += str(abs(x2 - x1) + 2 + abs(y2 - y1)) + '\n'
	print(ans)
main()


from sys import stdin, stdout
num = int(stdin.readline())
ans = []
for i in range(num):
	dis = 0
	(x1, y1, x2, y2) = map(int, stdin.readline().split())
	dis = abs(x2 - x1) + abs(y2 - y1)
	if y1 != y2 and x1 != x2:
		dis += 2
	ans += [dis]
for i in ans:
	stdout.write(str(i) + '\n')


for _ in range(int(input())):
	(a, b, x, y) = map(int, input().split())
	if a == x or b == y:
		print(abs(a - x) + abs(b - y))
	elif a == x and b == y:
		print('0')
	else:
		print(abs(a - x) + abs(b - y) + 2)


t = int(input())
for i in range(t):
	temp = [int(x) for x in input().split()]
	x1 = temp[0]
	y1 = temp[1]
	x2 = temp[2]
	y2 = temp[3]
	result = 0
	if abs(x2 - x1) > 0:
		result += abs(x2 - x1)
		if abs(y2 - y1) > 0:
			result += 2
			result += abs(y2 - y1)
	else:
		result += abs(y2 - y1)
	print(result)


from sys import stdin, stdout
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	(a, b, c, d) = mp()
	if b == d:
		pr(abs(a - c))
		return
	if a == c:
		pr(abs(b - d))
		return
	pr(abs(a - c) + abs(b - d) + 2)
for _ in range(inp()):
	solve()


for t in range(int(input())):
	(x1, y1, x2, y2) = input().split()
	a = int(x2) - int(x1)
	b = int(y2) - int(y1)
	if abs(a) == 0 or abs(b) == 0:
		print(abs(a) + abs(b))
	else:
		print(2 + abs(a) + abs(b))


import sys, os
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve_(a, b, c, d):
	if a == c:
		return abs(d - b)
	if b == d:
		return abs(a - c)
	return abs(a - c) + abs(b - d) + 2

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	pass
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def console(*args):
		pass

def solve(*args):
	console('----- solving ------')
	console(*args)
	console('----- ------- ------')
	return solve_(*args)
if True:
	inp = iter(sys.stdin.buffer.readlines())
	input = lambda : next(inp)
else:
	input = sys.stdin.buffer.readline
for case_num in range(int(input())):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	res = solve(x1, y1, x2, y2)
	print(res)


def solve(x1, y1, x2, y2):
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	d = dx + dy
	if dx != 0 and dy != 0:
		d += 2
	return d
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = [int(i) for i in input().split(' ')]
	ans = solve(x1, y1, x2, y2)
	print(ans)


for t in range(int(input())):
	(p, q, r, k) = map(int, input().split())
	if p == r:
		print(abs(q - k))
	elif q == k:
		print(abs(p - r))
	else:
		print(abs(p - r) + abs(q - k) + 2)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):
	print(stack)

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

def solve():
	(a, b, c, d) = sep()
	x = abs(a - c)
	y = abs(b - d)
	if x == 0 or y == 0:
		print(x + y)
	else:
		print(2 + x + y)
testcase(int(inp()))


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	steps = 0
	if x1 == x2 or y1 == y2:
		steps = max(abs(x1 - x2), abs(y1 - y2))
	else:
		steps = abs(x1 - x2) + abs(y1 - y2) + 2
	print(steps)


from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(x1, y1, x2, y2) = gil()
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if b == d:
		print(abs(c - a))
	elif c == a:
		print(abs(b - d))
	else:
		print(abs(c - a) + 2 + abs(b - d))


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(abs(y2 - y1))
		continue
	if y1 == y2:
		print(abs(x2 - x1))
		continue
	print(abs(x2 - x1) + abs(y2 - y1) + 2)


import sys
t = int(input().strip())
for a0 in range(t):
	l1 = [int(i) for i in input().split()]
	x1 = l1[0]
	x2 = l1[2]
	y1 = l1[1]
	y2 = l1[3]
	ans = 0
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		ans += abs(x1 - x2)
		ans += 2
		ans += abs(y1 - y2)
		print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	(x1, y1, x2, y2) = map(int, input().split())
	print(abs(x1 - x2) + abs(y1 - y2) + 2 * int(abs(x1 - x2) * abs(y1 - y2) != 0))


import sys
import itertools
import math
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(lp,) = I()
while lp:
	lp -= 1
	(x1, y1, x2, y2) = I()
	mx = abs(x2 - x1)
	my = abs(y2 - y1)
	if mx + my == 1:
		print(1)
	elif mx + my == 0:
		print(0)
	elif mx == 0:
		print(my)
	elif my == 0:
		print(mx)
	else:
		print(mx + my + 2)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	d1 = abs(d - b)
	d2 = abs(c - a)
	if d1 == 0:
		print(d2)
	elif d2 == 0:
		print(d1)
	else:
		print(d1 + d2 + 2)


def inlt():
	return list(map(int, input().split()))
t = int(input())
for i in range(t):
	inp = inlt()
	x1 = inp[0]
	y1 = inp[1]
	x2 = inp[2]
	y2 = inp[3]
	extra = 0
	if x1 == x2 or y1 == y2:
		extra = 0
	else:
		extra = 2
	print(abs(x1 - x2) + abs(y1 - y2) + extra)


import bisect

def solve(x1, y1, x2, y2):
	xdiff = abs(x2 - x1)
	ydiff = abs(y2 - y1)
	if xdiff > 0 and ydiff > 0:
		return xdiff + ydiff + 2
	elif xdiff == ydiff == 0:
		return 0
	else:
		return xdiff + ydiff
	pass
t = int(input())
ans = []
for i in range(t):
	s = [int(x) for x in input().split()]
	x1 = s[0]
	y1 = s[1]
	x2 = s[2]
	y2 = s[3]
	ans.append(solve(x1, y1, x2, y2))
for test in ans:
	print(test)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(x, y, a, b) = map(int, input().split())
	ans = 0
	if x != a and y != b:
		ans += 2
	ans += abs(x - a) + abs(y - b)
	print(ans)


def solve():
	(x1, y1, x2, y2) = map(int, input().split())
	dest = abs(x1 - x2) + abs(y1 - y2)
	if x1 == x2 or y1 == y2:
		print(dest)
	else:
		print(dest + 2)
for i in range(int(input())):
	solve()


q = int(input())
for i in range(q):
	(xa, ya, xb, yb) = map(int, input().split())
	if ya == yb:
		print(abs(xa - xb))
		continue
	if xa == xb:
		print(abs(ya - yb))
		continue
	print(abs(ya - yb) + abs(xb - xa) + 2)


test = int(input())
for i in range(test):
	(a, b, c, d) = list(map(int, input().split()))
	if a == c:
		print(abs(b - d))
	elif b == d:
		print(abs(a - c))
	else:
		print(abs(a - c) + abs(b - d) + 2)


for y in range(int(input())):
	(a1, b1, a2, b2) = map(int, input().split())
	ans = 0
	if a1 - a2 == 0:
		if b1 - b2 == 0:
			ans = 0
		else:
			ans = abs(b1 - b2)
	elif b1 - b2 == 0:
		ans = abs(a1 - a2)
	else:
		ans += abs(a1 - a2)
		ans += abs(b1 - b2)
		ans += 2
	print(ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if abs(y2 - y1) == 0 or abs(x2 - x1) == 0:
		print(abs(x2 - x1) + abs(y2 - y1))
	else:
		print(abs(y2 - y1) + abs(x2 - x1) + 2)


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	(x1, y1, x2, y2) = mi()
	if (x1, y1) == (x2, y2):
		print(0)
	elif x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


n = int(input())
for i in range(n):
	(xs, ys, xe, ye) = map(int, input().split())
	hor = abs(xs - xe)
	ver = abs(ys - ye)
	if hor > 0 and ver > 0:
		print(hor + ver + 2)
	else:
		print(max(hor, ver))


test = int(input())
for _ in range(test):
	(x1, y1, x2, y2) = map(int, input().split())
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	if dx == 0 or dy == 0:
		ans = 0
	else:
		ans = 2
	ans += dx + dy
	print(ans)


x = int(input())
for i in range(0, x):
	m = list(map(int, input().split()))[:4]
	if m[0] == m[2] or m[1] == m[3]:
		print(abs(m[0] - m[2]) + abs(m[1] - m[3]))
	else:
		print(abs(m[0] - m[2]) + abs(m[1] - m[3]) + 2)


q = int(input())
for _ in range(q):
	(x1, y1, x2, y2) = map(int, input().split())
	d = abs(x2 - x1) + abs(y2 - y1)
	if abs(x2 - x1) > 0 and abs(y2 - y1) > 0:
		print(d + 2)
	else:
		print(d)


t = int(input())
while t:
	t -= 1
	(x1, y1, x2, y2) = map(int, input().split())
	res = 0
	dh = abs(x2 - x1)
	dv = abs(y2 - y1)
	if dh != 0:
		res += dh
		if dv != 0:
			res += dv + 2
	else:
		res += dv
	print(res)


import io
import os
from collections import Counter, defaultdict, deque

def solve(X1, Y1, X2, Y2):
	if X1 == X2:
		return abs(Y1 - Y2)
	if Y1 == Y2:
		return abs(X1 - X2)
	return abs(X1 - X2) + abs(Y1 - Y2) + 2
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(X1, Y1, X2, Y2) = [int(x) for x in input().split()]
	ans = solve(X1, Y1, X2, Y2)
	print(ans)


tc = int(input())
for i in range(tc):
	(a, b, c, d) = map(int, input().split(' '))
	sum = abs(a - c) + abs(b - d)
	if a != c and b != d:
		print(sum + 2)
	else:
		print(sum)


t = int(input())
while t:
	(a, b, c, d) = map(int, input().split())
	ans = abs(a - c) + abs(b - d)
	if a != c and b != d:
		ans += 2
	print(ans)
	t -= 1


import sys
import math, bisect
sys.setrecursionlimit(10 ** 6)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict

def I():
	return int(sys.stdin.readline())

def neo():
	return map(int, sys.stdin.readline().split())

def Neo():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	(x1, y1, x2, y2) = neo()
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


from itertools import permutations
from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
t = int(input())
while t:
	t -= 1
	(x1, y1, x2, y2) = map(int, input().split())
	val1 = fabs(y1 - y2)
	val2 = fabs(x1 - x2)
	ans = int(val2 + val1)
	if val2 == 0 or val1 == 0:
		print(ans)
	else:
		print(ans + 2)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def msi():
	return map(str, input().split())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // gcd(x, y)
mod = 1000000007

def modInverse(b, m):
	g = gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def modu(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -999999999
	else:
		return inv * a % m
from math import log, sqrt, factorial, cos, tan, sin, radians, floor
import bisect
from decimal import *
getcontext().prec = 8
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def fn(n):
	c = 0
	while n % 2 == 0:
		c += 1
		n //= 2
	return c

def main():
	for _ in range(ii()):
		(a, b, c, d) = mi()
		if a == c:
			print(abs(d - b))
		elif b == d:
			print(abs(a - c))
		else:
			print(abs(a - c) + abs(b - d) + 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


test_cases = int(input())
for test_case in range(test_cases):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	if y2 == y1 or x2 == x1:
		print(abs(x2 - x1) + abs(y2 - y1))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


def main():
	num_testcases = int(input())
	results = []
	for _ in range(num_testcases):
		(x1, y1, x2, y2) = list(map(int, input().split()))
		res = abs(x2 - x1) + abs(y2 - y1)
		if y2 != y1 and x2 != x1:
			res += 2
		results.append(res)
	for res in results:
		print(res)
main()


import math
t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	x = abs(c - a)
	y = abs(d - b)
	if x == 0 and y == 0:
		print(0)
	elif x == 0 or y == 0:
		print(max(x, y))
	else:
		print(x + y + 2)


import sys

def input():
	return sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	[x1, y1, x2, y2] = list(map(int, input().split()))
	xdiff = abs(x1 - x2)
	ydiff = abs(y1 - y2)
	ans = xdiff + ydiff
	if xdiff != 0 and ydiff != 0:
		ans += 2
	print(ans)


import sys
from sys import stdin, stdout

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
t = int(sys.stdin.readline())
for tt in range(t):
	(a, b, c, d) = get_ints()
	if a == c or b == d:
		print(abs(c - a) + abs(d - b))
	else:
		print(abs(c - a) + abs(d - b) + 2)


import os
import math
import statistics
true = True
false = False
from functools import reduce
is_dev = 'vscode' in os.environ
if is_dev:
	inF = open('in.txt', 'r')
	outF = open('out.txt', 'w')

def ins():
	return list(map(int, input_().split(' ')))

def inss():
	return list(input_().split(' '))

def input_():
	if is_dev:
		return inF.readline()[:-1]
	else:
		return input()

def ranin():
	return range(int(input_()))

def print_(data):
	if is_dev:
		outF.write(str(data) + '\n')
	else:
		print(data)
epsilon = 1e-07
for _ in ranin():
	(bx, by, rx, ry) = ins()
	x_diff = abs(bx - rx)
	y_diff = abs(by - ry)
	if x_diff == 0 or y_diff == 0:
		print_(x_diff + y_diff)
	else:
		print_(x_diff + y_diff + 2)
if is_dev:
	outF.close()

	def compare_file():
		print(open('out.txt', 'r').read() == open('outactual.txt', 'r').read())
	compare_file()


import math
t = int(input())
for k1 in range(t):
	(x1, y1, x2, y2) = map(int, input().rstrip().split())
	if x1 == x2 and y1 == y2:
		print(0)
		continue
	if x1 == x2 and y1 != y2:
		print(abs(y2 - y1))
		continue
	if x1 != x2 and y1 == y2:
		print(abs(x2 - x1))
		continue
	print(abs(x2 - x1) + abs(y2 - y1) + 2)


for _ in range(int(input())):
	(x1, y1, x2, y2) = list(map(int, input().rstrip().split()))
	extra = 0 if x1 == x2 or y1 == y2 else 2
	print(abs(x2 - x1) + abs(y2 - y1) + extra)


for _ in range(int(input())):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	xSame = False
	ySame = False
	if x1 == x2:
		xSame = True
	if y1 == y2:
		ySame = True
	ans = 0
	ans += abs(x1 - x2)
	ans += abs(y1 - y2)
	if not ySame and (not xSame):
		ans += 2
	print(ans)


for j in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		xx = abs(x1 - x2) + abs(y1 - y2)
		print(xx + 2)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	(z1, z2) = (abs(x2 - x1), abs(y2 - y1))
	print([z1 + z2, z1 + z2 + 2][z1 > 0 and z2 > 0])


from sys import stdin
for _ in range(int(stdin.readline())):
	(x1, y1, x2, y2) = map(int, stdin.readline().split())
	ans = abs(x2 - x1) + abs(y2 - y1)
	if x1 != x2 and y1 != y2:
		ans += 2
	print(ans)


for _ in range(int(input())):
	arr = [int(i) for i in input().split()]
	ans = 0
	if arr[0] == arr[2]:
		print(abs(arr[1] - arr[3]))
	elif arr[1] == arr[3]:
		print(abs(arr[0] - arr[2]))
	else:
		print(abs(arr[0] - arr[2]) + abs(arr[1] - arr[3]) + 2)


from sys import stdin, stdout, setrecursionlimit

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			(x1, y1, x2, y2) = [int(x) for x in R().split()]
			ans.append(str(abs(x1 - x2) + abs(y1 - y2) + 2 * (x1 != x2 and y1 != y2)))
		W('\n'.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = (int(x) for x in input().split())
	if x1 == x2 and y1 == y2:
		print(0)
	elif x1 == x2 or y1 == y2:
		print(abs(x2 - x1) + abs(y2 - y1))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


t = int(input())
while t:
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 != x2 and y1 != y2:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
	else:
		print(abs(x1 - x2) + abs(y1 - y2))
	t -= 1


t = int(input())
for i in range(t):
	(x, y, x1, y1) = map(int, input().split(' '))
	if x == x1 or y == y1:
		print(abs(x - x1) + abs(y - y1))
	else:
		print(abs(x - x1) + abs(y - y1) + 2)


import sys
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(a, b, c, d) = inp()
	if a == c or b == d:
		print(abs(c - a) + abs(d - b))
	else:
		print(abs(c - a) + abs(d - b) + 2)


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(abs(y2 - y1))
		continue
	if y1 == y2:
		print(abs(x1 - x2))
		continue
	ans = abs(x1 - x2) + abs(y1 - y2) + 2
	print(ans)


for _ in range(int(input())):
	(a, b, x, y) = list(map(int, input().split()))
	if a == x or b == y:
		print(abs(a - x) + abs(b - y))
	else:
		print(1 + abs(a - x) + 1 + abs(b - y))


import time, math as mt, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(v):
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return adj

def solve():
	(x1, y1, x2, y2) = IP()
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(min(abs(x2 - x1) + abs(y2 - y1) + 2, abs(y2 - y1) + abs(x2 - x1) + 2))
	return
t = II()
for i in range(t):
	solve()


import sys
import math
input = sys.stdin.readline

def algo(arr):
	a = arr[:2]
	b = arr[2:]
	if a[0] == b[0] or a[1] == b[1]:
		return abs(a[0] - b[0]) + abs(a[1] - b[1])
	else:
		return abs(a[0] - b[0]) + abs(a[1] - b[1]) + 2
for _ in range(int(input())):
	arr = list(map(int, input().split()))
	res = algo(arr)
	print(res)


T = int(input())

def short(x1, y1, x2, y2):
	if x1 == x2:
		return abs(y1 - y2)
	if y1 == y2:
		return abs(x1 - x2)
	return 2 + abs(x1 - x2) + abs(y1 - y2)
for i in range(T):
	t = list(map(int, input().split()))
	print(short(t[0], t[1], t[2], t[3]))


from bisect import *
from collections import *
from math import *
from heapq import *
from typing import List
from itertools import *
from operator import *
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

@lru_cache(None)
def fact(x):
	if x < 2:
		return 1
	return fact(x - 1) * x

@lru_cache(None)
def per(i, j):
	return fact(i) // fact(i - j)

@lru_cache(None)
def com(i, j):
	return per(i, j) // fact(j)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 1
	res = 0
	for w in arr:
		res += w
		if res > x:
			res = w
		c += 1
	return c

def lowbit(n):
	return n & -n

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class smt:

	def __init__(self, l, r, arr):
		self.l = l
		self.r = r
		self.value = (1 << 31) - 1 if l < r else arr[l]
		mid = (l + r) // 2
		if l < r:
			self.left = smt(l, mid, arr)
			self.right = smt(mid + 1, r, arr)
			self.value &= self.left.value & self.right.value

	def setvalue(self, x, val):
		if self.l == self.r:
			self.value = val
			return
		mid = (self.l + self.r) // 2
		if x <= mid:
			self.left.setvalue(x, val)
		else:
			self.right.setvalue(x, val)
		self.value = self.left.value & self.right.value

	def ask(self, l, r):
		if l <= self.l and r >= self.r:
			return self.value
		val = (1 << 31) - 1
		mid = (self.l + self.r) // 2
		if l <= mid:
			val &= self.left.ask(l, r)
		if r > mid:
			val &= self.right.ask(l, r)
		return val

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d
t = N()
for i in range(t):
	(x, y, a, b) = RL()
	if x == a or y == b:
		ans = abs(x - a) + abs(y - b)
	else:
		ans = abs(x - a) + abs(y - b) + 2
	print(ans)


from math import *
from sys import *
t = int(stdin.readline())
for i in range(t):
	(x1, y1, x2, y2) = map(int, stdin.readline().split())
	ans = abs(x2 - x1) + abs(y2 - y1)
	if abs(x2 - x1) > 0 and abs(y2 - y1) > 0:
		ans += 2
	print(ans)


def solve():
	xdiff = abs(x1 - x2)
	ydiff = abs(y1 - y2)
	if ydiff == 0:
		return xdiff
	if xdiff == 0:
		return ydiff
	summ = xdiff + ydiff
	return summ + 2
T = int(input())
for t in range(T):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	ans = solve()
	print(ans)


t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	result = 0
	if c != a and b != d:
		result += 2
	result += abs(c - a) + abs(d - b)
	print(result)


n = int(input())
for i in range(n):
	x = [int(i) for i in input().split(' ')]
	xd = abs(x[0] - x[2])
	yd = abs(x[1] - x[3])
	if xd == 0:
		print(yd)
	elif yd == 0:
		print(xd)
	else:
		print(xd + 2 + yd)


for test in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = 0
	if x1 == x2:
		ans += abs(y1 - y2)
	else:
		ans += abs(x1 - x2)
		if y1 != y2:
			ans += 2
			ans += abs(y1 - y2)
	print(ans)


t = int(input())
l = []
for i in range(t):
	ch = input()
	L = [int(j) for j in ch.split()]
	s = 0
	if L[2] != L[0] and L[1] != L[3]:
		s += 2
	print(s + abs(L[2] - L[0]) + abs(L[3] - L[1]))


from sys import stdin
input = lambda : stdin.readline().strip()
for _ in range(int(input())):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	if x1 != x2 and y1 != y2:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
	elif x1 == x2:
		print(abs(y1 - y2))
	else:
		print(abs(x1 - x2))


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	if y1 == y2:
		print(abs(x1 - x2))
	elif x1 == x2:
		print(abs(y1 - y2))
	else:
		r = abs(x1 - x2) + abs(y1 - y2) + 2
		print(r)


for t in range(int(input())):
	res = 0
	[x1, y1, x2, y2] = list(map(int, input().split()))
	if x1 == x2 or y1 == y2:
		res = abs(x2 - x1) + abs(y2 - y1)
	else:
		res = abs(x2 - x1) + abs(y2 - y1) + 2
	print(res)


def main():
	(x1, y1, x2, y2) = map(int, input().split())
	dx = abs(x2 - x1)
	dy = abs(y2 - y1)
	cnt = 0
	if dx != 0:
		cnt += dx
		if dy != 0:
			cnt += 2
	if dy != 0:
		cnt += dy
	print(cnt)
for _ in range(int(input())):
	main()


t = int(input())
while t:
	a = list(map(int, input().split()))
	if a[0] == a[2] or a[1] == a[3]:
		print(abs(a[0] - a[2]) + abs(a[1] - a[3]))
	else:
		print(abs(a[0] - a[2]) + abs(a[1] - a[3]) + 2)
	t = t - 1


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 6 + 6
for _ in range(I()):
	(x, y, a, b) = R()
	print(abs(x - a) + abs(y - b) + (0 if x == a or b == y else 2))


t = int(input())
for e in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	d = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		print(d + 2)
	else:
		print(d)


n = int(input())
while n > 0:
	(x1, y1, x2, y2) = map(int, input().split())
	time = 0
	if (x1 >= x2 or x2 >= x1) and y1 == y2:
		time = abs(x1 - x2)
	elif (y1 >= y2 or y2 >= y1) and x1 == x2:
		time = abs(y1 - y2)
	else:
		time = 2 + abs(x1 - x2) + abs(y1 - y2)
	print(time)
	n -= 1


t = int(input())
for i in range(0, t):
	(a, b, c, d) = map(int, input().split())
	if a == c or b == d:
		ans = abs(c - a) + abs(d - b)
	else:
		ans = abs(c - a) - 1 + abs(d - b) - 1 + 4
	print(ans)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if min(abs(x2 - x1), abs(y2 - y1)) == 0:
		print(max(abs(x2 - x1), abs(y2 - y1)))
	else:
		print(abs(x2 - x1) - 1 + abs(y2 - y1) - 1 + 4)


for t in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	r = abs(a - c) + abs(b - d)
	if not (a == c or b == d):
		r += 2
	print(r)


from sys import stdin

class Input:

	def __init__(self):
		self.it = iter(stdin.readlines())

	def line(self):
		return next(self.it).strip()

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

def testcases(unknown=False):
	inpt = Input()

	def testcases_decorator(func):
		(cases,) = [float('Inf')] if unknown else inpt.array()
		while cases > 0:
			try:
				func(inpt)
				cases -= 1
			except StopIteration:
				break
	return testcases_decorator

@testcases()
def solve(inpt):
	(x1, y1, x2, y2) = inpt.array()
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		ans += 2
	print(ans)


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
T = int(input())
for _ in range(T):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = abs(x1 - x2) + abs(y1 - y2)
	if x1 == x2 and y1 == y2:
		print(0)
	elif x1 == x2 or y1 == y2:
		print(ans)
	else:
		print(ans + 2)


t = int(input())
for q in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	(a, b, c, d) = (L[0], L[1], L[2], L[3])
	nb = abs(a - c) + abs(b - d)
	if a != c and b != d:
		nb += 2
	print(nb)


def solve(a, b, c, d):
	if a == c or b == d:
		return abs(a - c) + abs(b - d)
	else:
		return abs(a - c) + abs(b - d) + 2
t = int(input())
while t:
	(a, b, c, d) = map(int, input().split())
	print(solve(a, b, c, d))
	t -= 1


t = int(input())
for t0 in range(t):
	a = list(map(int, input().split()))
	print(abs(a[0] - a[2]) + abs(a[1] - a[3]) + 2 * (a[0] != a[2] and a[1] != a[3]))


for _ in range(int(input())):
	c = list(map(int, input().split()))
	if c[0] == c[2]:
		ans = abs(c[1] - c[3])
	elif c[1] == c[3]:
		ans = abs(c[0] - c[2])
	else:
		ans = abs(c[0] - c[2]) + abs(c[1] - c[3]) + 2
	print(ans)


t = int(input())
c = []
for i in range(t):
	c.append([])
	k = input().split(' ')
	for j in range(4):
		c[i].append(int(k[j]))
for i in range(t):
	if c[i][0] != c[i][2] and c[i][1] != c[i][3]:
		print(abs(c[i][3] - c[i][1]) + abs(c[i][2] - c[i][0]) + 2)
	else:
		print(abs(c[i][3] - c[i][1]) + abs(c[i][2] - c[i][0]))


from sys import stdout, stdin
from collections import defaultdict, deque
import math
t = int(stdin.readline())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, stdin.readline().split())
	if x1 == x2 and y1 == y2:
		print(0)
	elif x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


for _ in range(int(input())):
	(x0, y0, x, y) = map(int, input().split())
	dx = abs(x0 - x)
	dy = abs(y0 - y)
	ans = dx + dy
	if x != x0 and y != y0:
		ans += 2
	print(ans)


import sys
i = 0
for line in sys.stdin:
	i += 1
	line = line.strip()
	if i == 1:
		n = int(line)
	else:
		x = [int(a) for a in line.strip().split(' ')]
		if x[0] == x[2] and x[1] == x[3]:
			print(0)
		elif x[0] == x[2]:
			print(abs(x[3] - x[1]))
		elif x[1] == x[3]:
			print(abs(x[2] - x[0]))
		else:
			print(abs(x[2] - x[0]) + abs(x[3] - x[1]) + 2)


import math
n = int(input())
for i in range(n):
	nn = input()
	(x1, y1, x2, y2) = map(int, nn.split(' '))
	if x1 == x2:
		print(int(math.fabs(y1 - y2)))
		continue
	if y1 == y2:
		print(int(math.fabs(x1 - x2)))
		continue
	print(int(math.fabs(x1 - x2) + 2 + math.fabs(y1 - y2)))


n = int(input())
for i in range(n):
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x2 - x1))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	c1 = abs(x2 - x1)
	c2 = abs(y2 - y1)
	if x1 == x2 or y1 == y2:
		print(c1 + c2)
	else:
		print(c1 + c2 + 2)


iter = int(input())
for i in range(0, iter):
	flagSide = 0
	flagUp = 0
	steps = 0
	pos = list(map(int, input().strip().split()))[:4]
	if pos[0] < pos[2]:
		flagSide = 1
		steps = steps + pos[2] - pos[0]
	if pos[0] > pos[2]:
		flagSide = 1
		steps = steps + pos[0] - pos[2]
	if pos[1] > pos[3]:
		flagUp = 1
		steps = steps + pos[1] - pos[3]
	if pos[1] < pos[3]:
		flagUp = 1
		steps = steps + pos[3] - pos[1]
	if flagSide == 1 and flagUp == 1:
		steps = steps + 2
	print(steps)


cases = int(input())
while cases:
	cases -= 1
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		ans = abs(x1 - x2) + abs(y2 - y1)
	else:
		ans = abs(x1 - x2) + abs(y2 - y1) + 2
	print(ans)


from sys import stdin
for i in range(int(stdin.readline())):
	(x1, y1, x2, y2) = map(int, stdin.readline().strip().split())
	a = abs(x1 - x2)
	b = abs(y1 - y2)
	if a == 0 or b == 0:
		z = a + b
	else:
		z = b + a + 2
	print(z)


ans = []
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	a = abs(x1 - x2)
	b = abs(y1 - y2)
	if min(a, b) == 0:
		ans.append(a + b)
	else:
		ans.append(a + b + 2)
print('\n'.join(map(str, ans)))


for _ in range(int(input())):
	(x, y, X, Y) = map(int, input().split())
	if y == Y:
		print(abs(x - X))
	elif x == X:
		print(abs(y - Y))
	else:
		(a, b) = (x + 1, y)
		p = abs(X + 1 - a)
		if x > X:
			(a, b) = (X - 1, y)
		else:
			(a, b) = (X + 1, y)
		p += abs(X - a) + abs(Y - b)
		print(p + 1)


from sys import stdin, stdout
ans = []

def main():
	(x, y, z, w) = list(map(int, stdin.readline().split()))
	count = abs(x - z) + abs(y - w)
	if x != z and y != w:
		count += 2
	ans.append(str(count))
for _ in range(int(input())):
	main()
stdout.write('\n'.join(ans))


import sys
import math
import itertools
import copy
import collections
input = sys.stdin.readline
T = int(input())
for case in range(T):
	(x0, y0, x, y) = map(int, input().split())
	if x0 == x and y0 == y:
		print(0)
		continue
	elif x0 == x or y0 == y:
		if x0 == x:
			print(abs(y - y0))
		else:
			print(abs(x - x0))
	else:
		print(abs(x - x0) + 2 + abs(y - y0))


for i in range(int(input())):
	li = list(map(int, input().split()))
	if li[0] == li[2]:
		print(abs(li[1] - li[3]))
	elif li[1] == li[3]:
		print(abs(li[0] - li[2]))
	else:
		su = abs(li[0] - li[2]) + abs(li[1] - li[3]) + 1 + 1
		print(su)


n = int(input())
for i in range(n):
	(x1, y1, x2, y2) = map(int, input().split())
	a = abs(x2 - x1)
	b = abs(y2 - y1)
	if a == 0 or b == 0:
		print(a + b)
	else:
		print(a + b + 2)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()
wrt = sys.stdout.write
pr = lambda *args, end='\n': wrt(' '.join([str(x) for x in args]) + end)
enum = enumerate
inf = float('inf')
cdiv = lambda x, y: -(-x // y)
mod = 1000000007
_T_ = inin()
for _t_ in range(_T_):
	(x1, y1, x2, y2) = inar()
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x2 - x1))
	else:
		print(abs(y2 - y1) + abs(x2 - x1) + 2)


import math
t = int(input())
s = []
for i in range(t):
	(x1, y1, x2, y2) = input().split()
	x1 = int(x1)
	y1 = int(y1)
	x2 = int(x2)
	y2 = int(y2)
	dif1 = math.trunc(math.fabs(y2 - y1))
	dif2 = math.trunc(math.fabs(x2 - x1))
	if dif1 == 0:
		s.append(dif2)
	elif dif2 == 0:
		s.append(dif1)
	else:
		s.append(dif1 + dif2 + 2)
for i in range(len(s)):
	print(s[i])


t = int(input())
for q in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	x = abs(x1 - x2)
	y = abs(y1 - y2)
	if x == 0 or y == 0:
		print(max(x, y))
	else:
		print(x + y + 2)


import math
import sys
x = 99999999999999
for _ in range(int(input())):
	(x, y, x1, y1) = map(int, input().split())
	if x == x1:
		print(abs(y - y1))
	elif y == y1:
		print(abs(x - x1))
	else:
		print(abs(x - x1) + abs(y - y1) + 2)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	xmove = abs(x1 - x2)
	ymove = abs(y1 - y2)
	time = xmove + ymove
	if xmove == 0 or ymove == 0:
		print(time)
	else:
		print(time + 2)


t = int(input())
for _ in range(t):
	coordinates = [int(value) for value in input().split(' ')]
	start_x = coordinates[0]
	start_y = coordinates[1]
	end_x = coordinates[2]
	end_y = coordinates[3]
	diff_x = abs(end_x - start_x)
	diff_y = abs(end_y - start_y)
	total = diff_x + diff_y
	if diff_x > 0 and diff_y > 0:
		total += 2
	print(total)


n = int(input())
for i in range(0, n):
	bush = [int(a) for a in input().split()]
	x1 = bush[0]
	y1 = bush[1]
	x2 = bush[2]
	y2 = bush[3]
	if x1 != x2 and y1 != y2:
		seconds = max(x1, x2) - min(x1, x2) + 2 + max(y1, y2) - min(y1, y2)
	elif x1 == x2 and y1 != y2:
		seconds = max(y1, y2) - min(y1, y2)
	elif y1 == y2 and x1 != x2:
		seconds = max(x1, x2) - min(x1, x2)
	else:
		seconds = 0
	print(seconds)


t = int(input())

def solve(x1, y1, x2, y2):
	if y1 == y2 or x1 == x2:
		s = 0
	else:
		s = 2
	print(abs(x1 - x2) + abs(y1 - y2) + s)
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	solve(x1, y1, x2, y2)


from sys import stdin, stdout
t = stdin.readline()
t = int(t)
while t:
	(x1, y1, x2, y2) = stdin.readline().split()
	x1 = int(x1)
	x2 = int(x2)
	y1 = int(y1)
	y2 = int(y2)
	diff_x = abs(x1 - x2)
	diff_y = abs(y1 - y2)
	if diff_x == 0:
		stdout.write(str(abs(y2 - y1)))
		print('\n')
	elif diff_y == 0:
		stdout.write(str(abs(x2 - x1)))
		print('\n')
	else:
		stdout.write(str(abs(y2 - y1) + abs(x2 - x1) + 2))
		print('\n')
	t -= 1


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	arr = [l[2] - l[0], l[3] - l[1]]
	if arr[0] == 0 or arr[1] == 0:
		print(abs(arr[0]) + abs(arr[1]))
	else:
		print(abs(arr[0]) + abs(arr[1]) + 2)


n = int(input())
x = []
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	x = x + [a, b, c, d]
for j in range(0, 4 * n, 4):
	if x[j] == x[j + 2]:
		print(abs(int(x[j + 1]) - int(x[j + 3])))
	elif x[j + 1] == x[j + 3]:
		print(abs(int(x[j]) - int(x[j + 2])))
	else:
		print(abs(int(x[j + 1]) - int(x[j + 3])) + abs(int(x[j]) - int(x[j + 2])) + 2)


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	k = 0
	sumo = 0
	if a == c:
		k = k + 1
	if b == d:
		k = k + 1
	if k == 2:
		print('0')
	elif k == 1:
		sumo = max(a - c, c - a, b - d, d - b)
		print(sumo)
	else:
		sumo = max(a - c, c - a) + max(b - d, d - b) + 2
		print(sumo)


t = int(input())
while t > 0:
	t = t - 1
	(x1, y1, x2, y2) = input().split()
	x1 = int(x1)
	y1 = int(y1)
	x2 = int(x2)
	y2 = int(y2)
	diff_x = abs(x1 - x2)
	diff_y = abs(y2 - y1)
	time = 0
	if diff_x == 0:
		time = diff_y
	if diff_y == 0:
		time = diff_x
	if diff_y > 0 and diff_x > 0:
		time = diff_x + diff_y + 2
	print(time)


import math
import sys
from collections import OrderedDict

class Graph:

	def __init__(self, Nodes, is_directed=False):
		self.nodes = Nodes
		self.adj_list = {}
		self.is_directed = is_directed
		for node in self.nodes:
			self.adj_list[node] = []

	def add_edge(self, u, v):
		self.adj_list[u].append(v)
		if self.is_directed == False:
			self.adj_list[v].append(u)

	def print_graph(self):
		for node in self.nodes:
			print(node, '->', self.adj_list[node])

	def degree_node(self, node):
		return len(self.adj_list[node])

	def dfsUTIL(self, v, visited, parents=[]):
		visited[v] = True
		for i in self.adj_list[v]:
			if visited[i] == False:
				self.dfsUTIL(i, visited, parents)
				parents.append(i)

	def dfs(self, v):
		visited = [False] * (max(self.adj_list) + 1)
		parents = [v]
		self.dfsUTIL(v, visited, parents)
		return len(parents)

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def swap(a, b):
	temp = a
	a = b
	b = temp

def seive_primes(n):
	flag = [0] * (n + 10)
	flag[1] = flag[0] = 1
	i = 2
	while i * i <= n + 1:
		if flag[i] == 0:
			j = i * i
			while j <= n + 1:
				flag[j] = 1
				j += i
		i += 1
	return flag

def factors(n):
	d = {}
	while n % 2 == 0:
		if 2 in d:
			d[2] += 1
		else:
			d[2] = 1
		n /= 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
			n /= i
	n = int(n)
	if n > 1:
		d[n] = 1
	return d

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def alphabates():
	return 'abcdefghijklmnopqrstuvwxyz'

def binary_search(ls, n, flag):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = (low + hi) // 2
		if ls[mid] == flag:
			return mid
		elif ls[mid] > flag:
			hi = mid - 1
		else:
			low = mid + 1
	return -1

def qdrt(a, b, c):
	chk = b * b - 4 * a * c
	if chk >= 0:
		ans1 = (-b + chk ** 0.5) / (2 * a)
		ans2 = (-b - chk ** 0.5) / (2 * a)
		return [int(ans1), int(ans2)]
	return -1

def permutation(n, r):
	if n < r:
		return 0
	ans = 1
	for i in range(n - r + 1, n + 1):
		ans *= i
	return ans

def combination(n, r):
	if n < r:
		return 0
	ans = 1
	for i in range(r):
		ans *= n - i
	div = 1
	for i in range(2, r + 1):
		div *= i
	return ans // div

def ispow2(n):
	ans = int(math.log(n, 2))
	if 2 ** ans == n:
		return True
	return False

def sumn(n):
	return n * (n + 1) // 2

def arrinp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(int, input().split())

def main():
	t = int(input())
	for _ in range(t):
		(x1, y1, x2, y2) = mult_inp()
		dist1 = abs(x1 - x2)
		dist2 = abs(y1 - y2)
		if dist1 != 0 and dist2 != 0:
			print(dist1 + dist2 + 2)
		else:
			print(dist2 + dist1)
main()


for t in range(int(input())):
	StartFinish = list(map(int, input().split(' ')))
	Start = StartFinish[:len(StartFinish) // 2]
	Finish = StartFinish[len(StartFinish) // 2:]
	dif = [x - y for (x, y) in zip(Start, Finish)]
	count = 0
	if -1 <= dif[0] + dif[1] <= 1 and -1 <= dif[0] - dif[1] <= 1:
		for x in dif:
			while x != 0:
				if x < 0:
					x = x + 1
					count = count + 1
				if x > 0:
					x = x - 1
					count = count + 1
	else:
		cur = 0
		for x in dif:
			while x != 0:
				if x < 0:
					count = count - x
					x = x - x
					cur = cur + 1
				if x > 0:
					count = count + x
					x = x - x
					cur = cur + 1
		if cur == 2:
			count = count + 2
	print(count)


def solve():
	n = int(input())
	r = []
	v = []
	for i in range(n):
		k = 0
		x = input()
		v = x.split(' ')
		x = int(v[0])
		y = int(v[1])
		x1 = int(v[2])
		y1 = int(v[3])
		if x != x1 and y != y1:
			k = k + 2
		k = k + abs(x - x1) + abs(y - y1)
		r.append(k)
	for i in range(n):
		print(int(r[i]))
solve()


x = int(input(''))
answers = []
for i in range(x):
	(x1, y1, x2, y2) = input().split()
	x1 = int(x1)
	x2 = int(x2)
	y1 = int(y1)
	y2 = int(y2)
	if y1 == y2 and x2 == x1:
		answers = answers + [0]
	elif y1 == y2 and (not x2 == x1):
		answers = answers + [abs(x2 - x1)]
	elif x2 == x1 and (not y1 == y2):
		answers = answers + [abs(y2 - y1)]
	else:
		seconds = abs(x2 - x1) + abs(y2 - y1) + 2
		answers = answers + [seconds]
for i in answers:
	print(i)


t = int(input())
for f in range(t):
	(a, b, c, d) = [int(x) for x in input().split()]
	if abs(a - c) == 0 or abs(b - d) == 0:
		print(abs(a - c + b - d))
	else:
		print(abs(a - c) + abs(b - d) + 2)


from sys import stdin
number = int(stdin.readline())
for _ in range(number):
	(x1, y1, x2, y2) = (int(value) for value in stdin.readline().strip('\n').split())
	x = abs(x1 - x2)
	y = abs(y1 - y2)
	if not x or not y:
		print(str(x + y))
	else:
		print(str(x + y + 2))


for i in range(int(input())):
	(x1, y1, x2, y2) = [int(num) for num in input().split()]
	if x1 == x2 and y1 == y2:
		print(0)
		continue
	elif x1 == x2 and y1 != y2:
		print(abs(y2 - y1))
		continue
	elif y1 == y2 and x1 != x2:
		print(abs(x2 - x1))
		continue
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


def way_search(x1: int, y1: int, x2: int, y2: int):
	sumway = 0
	x_way = abs(x2 - x1)
	sumway = sumway + x_way
	y_way = abs(y2 - y1)
	sumway = sumway + y_way
	if y_way > 0 and x_way > 0:
		sumway = sumway + 2
	return sumway
tests = int(input())
for i in range(tests):
	s = input()
	cords = [int(i) for i in s.split(' ')]
	print(way_search(cords[0], cords[1], cords[2], cords[3]))


t = int(input())
ans = list()
for i in range(0, t):
	a = list(map(int, input().split()))
	if a[0] == a[2]:
		ans.append(abs(a[1] - a[3]))
	elif a[1] == a[3]:
		ans.append(abs(a[0] - a[2]))
	else:
		ans.append(abs(a[1] - a[3]) + abs(a[0] - a[2]) + 2)
for i in range(0, t):
	print(ans[i])


t = int(input())
for _ in range(t):
	(x, y, s, t) = map(int, input().split())
	if x == s and y == t:
		print(0)
	elif x == s or y == t:
		print(abs(x - s) + abs(y - t))
	else:
		print(abs(x - s) + abs(y - t) + 2)


for _ in range(int(input())):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x2 - x1))
	else:
		ans = abs(x2 - x1)
		ans += abs(y2 - y1)
		ans += 2
		print(ans)


num = int(input())
for it in range(num):
	(a, b, c, d) = map(int, input().split(' '))
	difx = abs(a - c)
	dify = abs(b - d)
	if difx == 0 and dify == 0:
		print(0)
	elif difx == 0 or dify == 0:
		print(difx + dify)
	else:
		print(difx + dify + 2)


t = int(input())
i = 0
while i < t:
	xy = list(map(int, input().split()))
	x1 = xy[0]
	y1 = xy[1]
	x2 = xy[2]
	y2 = xy[3]
	answer = 0
	if x1 == x2 or y1 == y2:
		if x1 == x2:
			answer = abs(y1 - y2)
		else:
			answer = abs(x1 - x2)
	else:
		answer = abs(x1 - x2) + abs(y1 - y2) + 2
	print(answer)
	i += 1


T = int(input())

def solve(x1, y1, x2, y2):
	a = abs(x2 - x1)
	b = abs(y2 - y1)
	ans = a + b
	if a != 0 and b != 0:
		ans += 2
	return ans
for _ in range(T):
	(x1, y1, x2, y2) = map(int, input().split())
	print(solve(x1, y1, x2, y2))


def solve(x1, y1, x2, y2):
	if x1 == x2:
		return abs(y1 - y2)
	if y1 == y2:
		return abs(x1 - x2)
	return abs(x1 - x2) + abs(y1 - y2) + 2

def main(input_path=0):
	with open(input_path) as f:
		t = int(f.readline())
		for _ in range(t):
			(x1, y1, x2, y2) = [int(x) for x in f.readline().strip().split(' ')]
			print(solve(x1, y1, x2, y2))
main()


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if y1 == y2:
		if x2 > x1:
			print(x2 - x1)
		else:
			print(x1 - x2)
	elif x1 == x2:
		if y2 > y1:
			print(y2 - y1)
		else:
			print(y1 - y2)
	else:
		res = 0
		if x1 > x2:
			res += x1 - x2
		else:
			res += x2 - x1
		if y1 > y2:
			res += y1 - y2
		else:
			res += y2 - y1
		print(res + 2)


from sys import stdin, stdout

def II():
	return int(stdin.readline())

def SI():
	return stdin.readline()[:-1]

def MI():
	return map(int, stdin.readline().split())

def LI():
	return list(map(int, stdin.readline().split()))

def solve():
	(x1, y1, x2, y2) = MI()
	ans = 0
	if abs(y2 - y1) == 0:
		ans = abs(x2 - x1)
	elif abs(x2 - x1) == 0:
		ans = abs(y2 - y1)
	else:
		ans = abs(x2 - x1) + abs(y2 - y1) + 2
	stdout.write(str(ans) + '\n')
t = II()
for _ in range(t):
	solve()


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	if dx == 0 and dy == 0:
		print(0)
	elif dx == 0 or dy == 0:
		print(max(dx, dy))
	else:
		print(dx + dy + 2)


t = int(input())
buf = []
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		buf.append(abs(x1 - x2) + abs(y1 - y2))
	else:
		buf.append(abs(x1 - x2) + abs(y1 - y2) + 2)
print('\n'.join(map(str, buf)))


from collections import defaultdict
mod = 10 ** 9 + 7
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return pow(N, mod - 2, mod)

def main():
	T = int(input())
	for _ in range(T):
		(x1, y1, x2, y2) = getlist()
		if x1 == x2:
			print(abs(y1 - y2))
		elif y1 == y2:
			print(abs(x1 - x2))
		else:
			ans = abs(x1 - x2) + abs(y1 - y2) + 2
			print(ans)
main()


t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	k = abs(c - a)
	m = abs(d - b)
	if k == 0 or m == 0:
		print(k + m)
	else:
		print(k + m + 2)


import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(x1, y1, x2, y2) = get_ints()
	x = abs(x2 - x1)
	y = abs(y2 - y1)
	if x == 0 or y == 0:
		print(x + y)
	else:
		print(x + y + 2)


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
for _ in range(II()):
	(x1, y1, x2, y2) = MI()
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	if dx == 0 or dy == 0:
		print(dx + dy)
		continue
	print(dx + dy + 2)


ncases = int(input())
for tcase in range(ncases):
	line = list(map(int, input().split(' ')))
	startr = line[0]
	startc = line[1]
	endr = line[2]
	endc = line[3]
	if startr == endr and startc == endc:
		print('0')
		continue
	if startr == endr:
		print(abs(endc - startc))
		continue
	if startc == endc:
		print(abs(endr - startr))
		continue
	print(abs(startr - endr) + abs(startc - endc) + 2)


import os
import sys
input = sys.stdin.readline

def func(x1, y1, x2, y2):
	if abs(x1 - x2) == 0:
		return abs(y1 - y2)
	elif abs(y1 - y2) == 0:
		return abs(x1 - x2)
	else:
		return abs(x1 - x2) + abs(y1 - y2) + 2

def main():
	num = 0
	s = input()
	num = int(s)
	for _ in range(num):
		line = input()
		(x1, y1, x2, y2) = map(int, line.split(' '))
		res = func(x1, y1, x2, y2)
		print(res)
main()


tc = int(input())
for tcc in range(1, tc + 1):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	tot = 0
	tot = tot + abs(x2 - x1)
	tot = tot + abs(y2 - y1)
	if abs(x2 - x1) >= 1 and abs(y2 - y1) >= 1:
		tot += 2
	print(tot)


t = int(input())
while t > 0:
	t -= 1
	(a, b, c, d) = map(int, input().split())
	xd = abs(a - c)
	yd = abs(b - d)
	if xd > 0 and yd > 0:
		print(xd + yd + 2)
	else:
		print(xd + yd)


t = int(input())

def solution(a, b, c, d):
	result = abs(a - c) + abs(b - d)
	if a != c and b != d:
		result += 2
	return result
for _ in range(t):
	print(solution(*map(int, input().split())))


from sys import stdin, stdout
from math import ceil, floor
for _ in range(int(stdin.readline())):
	(x1, y1, x2, y2) = list(map(int, stdin.readline().split()))
	if x1 == x2:
		print(abs(y2 - y1))
		continue
	if y1 == y2:
		print(abs(x2 - x1))
		continue
	ans = abs(y2 - y1) + abs(x2 - x1)
	ans = ans + 2
	print(ans)


t = int(input())
while t != 0:
	t = t - 1
	(a, b, c, d) = map(int, input().split())
	f1 = False
	f2 = False
	if b == d:
		f1 = True
	if a == c:
		f2 = True
	if f1 and f2:
		print('0')
		continue
	elif f2:
		print(max(b, d) - min(b, d))
	elif f1:
		print(max(a, c) - min(a, c))
	else:
		print(max(b, d) - min(b, d) + max(a, c) - min(a, c) + 2)


answers = []
n = int(input())
for i in range(0, n):
	k = 1
	(a0, b0, a1, b1) = map(int, input().split())
	if (b0 == b1) | (a0 == a1):
		k -= 1
	answers.append(abs(a1 - a0) + abs(b1 - b0) + k * 2)
for i in answers:
	print(i)


T = int(input())
for _ in range(T):
	(x1, y1, x2, y2) = map(int, input().split())
	dif_x = abs(x1 - x2)
	dif_y = abs(y1 - y2)
	res = dif_x + dif_y
	if min(dif_x, dif_y) > 0:
		res += 2
	print(res)


import math
import sys
import collections
import bisect
input = sys.stdin.readline
flush = sys.stdout.flush
readint = lambda : int(input())
readintm = lambda : map(int, input().strip().split())
readintl = lambda : list(map(int, input().strip().split()))
readfloatm = lambda : map(float, input().strip().split())
readfloatl = lambda : list(map(float, input().strip().split()))
readstr = lambda : input().strip()
readstrl = lambda : list(input().strip())
join = lambda x, l: x.join(map(str, l))
print = lambda *x: sys.stdout.write(' '.join(map(str, x)) + '\n')
printl = lambda l: sys.stdout.write(' '.join(map(str, l)) + '\n')
ceil = lambda x, y: (x + y - 1) // y
mod = 1000000007
for _ in range(readint()):
	(x1, y1, x2, y2) = readintm()
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x2 - x1))
	else:
		print(2 + abs(y2 - y1) + abs(x2 - x1))


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	if dx == 0:
		ans = dy
	elif dy == 0:
		ans = dx
	else:
		ans = dx + dy + 2
	print(ans)


q = int(input())
for i in range(q):
	n = [int(i) for i in input().split()]
	xd = abs(n[0] - n[2])
	yd = abs(n[1] - n[-1])
	result = xd + yd
	if result <= 1:
		print(result)
	elif xd == 0:
		print(result)
	elif yd == 0:
		print(result)
	else:
		print(result + 2)


n = int(input())
lst = []
sec = 0
for i in range(n):
	lst.clear()
	lst = list(map(int, input().split()))
	if abs(lst[2] - lst[0]) == 1 and lst[1] == lst[3]:
		sec = 1
	elif abs(lst[1] - lst[3]) == 1 and lst[0] == lst[2]:
		sec = 1
	elif abs(lst[2] - lst[0] == 0) or abs(lst[3] - lst[1] == 0):
		sec = abs(lst[0] - lst[2]) + abs(lst[1] - lst[3])
	else:
		sec = abs(lst[0] - lst[2]) + abs(lst[1] - lst[3]) + 2
	print(sec)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(a, b, c, d) = I()
	an = abs(a - c) + abs(d - b)
	if a != c and b != d:
		an += 2
	print(an)


n = int(input())
for _ in range(n):
	coord = [int(i) for i in input().split()]
	x_dist = abs(coord[2] - coord[0])
	y_dist = abs(coord[3] - coord[1])
	if x_dist and y_dist:
		print(x_dist + y_dist + 2)
	elif x_dist == 0 or y_dist == 0:
		print(x_dist + y_dist)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]
for _ in range(val()):
	(a, b, c, d) = li()
	xdist = abs(a - c)
	ydist = abs(b - d)
	ans = 0
	if xdist:
		ans += xdist
	if ydist:
		ans += ydist
	if xdist and ydist:
		ans += 2
	print(ans)


t = int(input())
for i in range(t):
	res = 0
	line = input().strip().split()
	(x1, y1, x2, y2) = [int(_) for _ in line]
	x = abs(x2 - x1)
	y = abs(y2 - y1)
	(x, y) = (min(x, y), max(x, y))
	if x != 0:
		res += x
		res += 2
	res += y
	print(res)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
n = int(input())
for _ in range(n):
	(x1, y1, x2, y2) = get_ints()
	c = abs(x2 - x1)
	d = abs(y2 - y1)
	k = c + d
	if c * d > 0:
		k += 2
	print(k)


def main():
	for _ in range(int(input())):
		(x1, y1, x2, y2) = map(int, input().split())
		if x1 == x2 and y1 == y2:
			print(0)
			continue
		if x1 == x2 or y1 == y2:
			print(abs(x1 - x2) + abs(y1 - y2))
			continue
		t = 0
		x = x2 - x1
		y = y2 - y1
		if abs(x) <= abs(y):
			t += abs(x)
			x1 += x
			if x1 == x2 and y1 == y2:
				print(t)
				continue
			t += 2
			t += abs(y2 - y1)
		else:
			t += abs(y)
			y1 += y
			if x1 == x2 and y1 == y2:
				print(t)
				continue
			t += 2
			t += abs(x2 - x1)
		print(t)
main()


import sys, os.path
from collections import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x2 - x1))
	else:
		print(abs(x2 - x1) + 1 + abs(y2 - y1) + 1)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(x, y, a, b) = invr()
	if x == a:
		print(abs(y - b))
	elif y == b:
		print(abs(x - a))
	else:
		print(abs(x - a) + abs(y - b) + 2)


import sys, math, cmath, time, collections
start_time = time.time()

def solve():
	(a, b, c, d) = invr()
	print(abs(a - c) + abs(b - d) if a == c or b == d else abs(b - d) + 2 + abs(a - c))

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


t = int(input())
for x in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	turnRequired = True
	if x1 == x2 or y1 == y2:
		turnRequired = False
	timeTaken = abs(x1 - x2) + abs(y1 - y2)
	if turnRequired:
		timeTaken += 2
	print(timeTaken)


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


def rabbit_jump(coord):
	(x1, y1, x2, y2) = coord
	xd = abs(x1 - x2)
	yd = abs(y1 - y2)
	min_d = xd + yd
	if xd != 0 and yd != 0:
		min_d += 2
	return min_d
t = int(input())
for i in range(t):
	print(rabbit_jump(list(map(int, input().split()))))


def wabbit():
	s = 0
	sum = 0
	a = list(map(int, input().strip().split()))
	s = abs(a[2] - a[0]) + abs(a[3] - a[1])
	if a[2] != a[0] and a[3] != a[1]:
		s = abs(a[2] - a[0]) + abs(a[3] - a[1]) + 2
	else:
		s = abs(a[2] - a[0]) + abs(a[3] - a[1])
	print(s)
t = int(input())
for i in range(t):
	wabbit()


import sys

def get_min_steps(x1, y1, x2, y2):
	if x1 == x2:
		return abs(y2 - y1)
	if y1 == y2:
		return abs(x2 - x1)
	return abs(y2 - y1) + abs(x2 - x1) + 2

def main():
	stream = sys.stdin
	n = int(stream.readline())
	for i in range(n):
		(x1, y1, x2, y2) = [int(tok) for tok in stream.readline().split()]
		print(get_min_steps(x1, y1, x2, y2))
main()


def main():
	t = int(input())
	for _ in range(t):
		(a, b, c, d) = map(int, input().split())
		if a == c:
			print(abs(b - d))
		elif b == d:
			print(abs(a - c))
		else:
			print(abs(a - c) + abs(b - d) + 2)
main()


def abs(x1, y1, x2, y2):
	dx = x1 - x2 if x1 >= x2 else x2 - x1
	dy = y1 - y2 if y1 >= y2 else y2 - y1
	return dx + dy
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		print(abs(x1, y1, x2, y2))
	else:
		print(abs(x1, y1, x2, y2) + 2)


t = int(input())
arr = []
for i in range(t):
	arr.append(list(map(int, input().split())))
ans = []
for i in arr:
	moves = 0
	x = 0
	y = 0
	x = abs(i[0] - i[2])
	y = abs(i[1] - i[3])
	if x == 0:
		moves = y
	elif y == 0:
		moves = x
	else:
		moves = x + y + 2
	ans.append(moves)
for i in ans:
	print(i)


import sys

def take_int(line):
	return int(line)

def take_strings(line):
	return list(line.split())

def take_character_list(line):
	return list(line[:len(line) - 1])

def take_int_list(line):
	return list(map(int, line.split()))

def move_time(x1, y1, x2, y2):
	return int(abs(x1 - x2) + abs(y1 - y2))

def cal_time(x1, y1, x2, y2):
	if x1 == x2 and y1 == y2:
		return (0, None)
	elif (x1, y1) == (x2 + 1, y2):
		return (1, x2 + 1, y2)
	elif (x1, y1) == (x2, y2 + 1):
		return (1, x2, y2 + 2)
	elif (x1, y1) == (x2 - 1, y2):
		return (1, x2 - 2, y2)
	elif (x1, y1) == (x2, y2 - 1):
		return (1, x2, y2 - 2)
	elif x1 == x2:
		return (abs(y2 - y1), None)
	elif y1 == y2:
		return (abs(x2 - x1), None)
	else:
		return (abs(y2 - y1) + abs(x2 - x1) + 2, None)
i = 0
n = 0
lst = []
for line in sys.stdin:
	if i == 0:
		n = take_int(line)
	else:
		lst.append(take_int_list(line))
	i += 1
for sublst in lst:
	print(cal_time(sublst[0], sublst[1], sublst[2], sublst[3])[0])


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	t = int(input())
	for _ in range(t):
		(x1, y1, x2, y2) = inar()
		if abs(y2 - y1) == 0 or abs(x2 - x1) == 0:
			print(abs(x2 - x1) + abs(y2 - y1))
		else:
			print(abs(x2 - x1) + abs(y2 - y1) + 2)
main()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	(x1, y1, x2, y2) = stdarr()
	res = abs(x1 - x2) + abs(y2 - y1)
	if x1 - x2 == 0 or y1 - y2 == 0:
		print(res)
	else:
		print(res + 2)


n = int(input())
for i in range(n):
	st = list(map(int, input().split(' ')))
	if st[2] != st[0] and st[1] != st[3]:
		print(abs(st[2] - st[0]) + abs(st[3] - st[1]) + 2)
	else:
		print(abs(st[2] - st[0]) + abs(st[3] - st[1]))


def f():
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		return abs(x1 - x2) + abs(y1 - y2)
	else:
		return abs(x1 - x2) + abs(y1 - y2) + 2
t = int(input())
for i in range(t):
	print(f())


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		(x1, y1, x2, y2) = map(int, input().split())
		if x1 == x2 or y1 == y2:
			print(abs(x1 - x2) + abs(y1 - y2))
		else:
			print(abs(x1 - x2) + abs(y1 - y2) + 2)
main()


from math import *
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split(' '))
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		ans = abs(x1 - x2) + abs(y1 - y2) + 2
		print(ans)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	(a, b, c, d) = (l[0], l[1], l[2], l[3])
	if a == c or b == d:
		print(abs(a - c) + abs(b - d))
	else:
		x = abs(a - c)
		y = abs(b - d)
		print(x + y + 2)


for i in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	a = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		a += 2
	print(a)


def main(x):
	a = abs(x[0] - x[2])
	b = abs(x[1] - x[3])
	if a == 0 and b == 0:
		print(0)
		return 0
	if a == 0 or b == 0:
		print(a + b)
		return
	print(a + b + 2)
	return
n = int(input())
for i in range(n):
	x = list(map(int, input().split(' ')))
	main(x)


t = int(input())
while t:
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	a = abs(x1 - x2)
	b = abs(y1 - y2)
	if a == 0 or b == 0:
		print(a + b)
		t -= 1
		continue
	else:
		print(a + b + 2)
		t -= 1
		continue


for _ in range(0, int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	a = [abs(x1 - x2), abs(y1 - y2)]
	print(sum(a) + all(a) * 2)


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
for i in range(INT()):
	(x1, y1, x2, y2) = MAP()
	up = abs(y1 - y2)
	left = abs(x1 - x2)
	ans = up + left + 2
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = 0
	if abs(x2 - x1):
		ans += abs(x2 - x1)
		if abs(y2 - y1):
			ans += abs(y2 - y1) + 2
	elif abs(y2 - y1):
		ans += abs(y2 - y1)
	print(ans)


def solve():
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		d = abs(y1 - y2)
		print(d)
	elif y1 == y2:
		d = abs(x1 - x2)
		print(d)
	else:
		d = abs(x1 - x2) + abs(y1 - y2) + 2
		print(d)
	return

def main():
	t = int(input())
	for i in range(t):
		solve()
	return
main()


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 and y1 == y2:
		print(0)
	elif x1 == x2:
		d = 0
		if y2 > y1:
			d = y2 - y1
		else:
			d = y1 - y2
		print(d)
	elif y1 == y2:
		d = 0
		if x2 > x1:
			d = x2 - x1
		else:
			d = x1 - x2
		print(d)
	else:
		x = 0
		y = 0
		if x2 > x1:
			x = x2 - x1
		else:
			x = x1 - x2
		if y2 > y1:
			y = y2 - y1
		else:
			y = y1 - y2
		print(x + y + 2)


from collections import defaultdict, deque

def solve():
	(x1, y1, x2, y2) = map(int, input().split())
	if x2 == x1:
		print(abs(y2 - y1))
	elif y2 == y1:
		print(abs(x2 - x1))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


t = int(input())
while t > 0:
	t -= 1
	(x, y, x2, y2) = map(int, input().split())
	ans1 = abs(x - x2)
	ans2 = abs(y - y2)
	if ans1 == 0 or ans2 == 0:
		print(ans1 + ans2)
	else:
		print(ans1 + ans2 + 2)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	diff = abs(x1 - x2)
	d2 = abs(y1 - y2)
	if d2 == 0 or diff == 0:
		print(diff + d2)
	else:
		print(diff + d2 + 2)


def main():
	test = int(input())
	for test_i in range(test):
		(a, b, c, d) = input().split()
		a = int(a)
		b = int(b)
		c = int(c)
		d = int(d)
		if a == c:
			print(abs(d - b))
		elif b == d:
			print(abs(a - c))
		else:
			print(abs(a - c) + abs(b - d) + 2)
main()


import bisect
import itertools
import math
import random
from collections import Counter, deque, defaultdict
from functools import reduce
from operator import xor
mod = 10 ** 9 + 7

def lmi():
	return list(map(int, input().split()))

def main():
	t = int(input())
	for _ in range(t):
		(x1, y1, x2, y2) = lmi()
		solve(x1, y1, x2, y2)

def solve(x1, y1, x2, y2):
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
main()


for i in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	delta_x = abs(x1 - x2)
	delta_y = abs(y1 - y2)
	if delta_x == 0 or delta_y == 0:
		print(delta_x + delta_y)
	else:
		print(delta_x + delta_y + 2)


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	return [[default for j in range(m)] for i in range(n)]

def arr3D(n, m, r, default=0):
	return [[[default for k in range(r)] for j in range(m)] for i in range(n)]

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}
for _ in range(int(input())):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	if x1 == x2 or y1 == y2:
		print(abs(x2 - x1) + abs(y2 - y1))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


import math
t = int(input())
for w in range(t):
	(a, b, c, d) = (int(i) for i in input().split())
	if c == a:
		print(abs(d - b))
	elif d == b:
		print(abs(c - a))
	else:
		print(abs(c - a) + 2 + abs(d - b))


import os
import sys
from io import BytesIO, IOBase
_str = str
BUFSIZE = 8192

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def inp():
	return sys.stdin.readline().rstrip()

def mpint():
	return map(int, inp().split(' '))

def itg():
	return int(inp())

def solve():
	(x1, y1, x2, y2) = mpint()
	d1 = abs(x1 - x2)
	d2 = abs(y1 - y2)
	if d1 and d2:
		return 2 + d1 + d2
	return d1 + d2

def main():
	for _ in range(itg()):
		print(solve())
DEBUG = 0
URL = ''
if DEBUG == 1:
	import requests
	from ACgenerator.Y_Test_Case_Runner import TestCaseRunner
	runner = TestCaseRunner(main, URL)
	inp = runner.input_stream
	print = runner.output_stream
	runner.checking()
elif DEBUG == 2:
	main()
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	main()


t = int(input())
for i in range(t):
	a = [int(x) for x in input().split()]
	if a[0] == a[2] or a[1] == a[3]:
		print(max(a[2] - a[0] + a[3] - a[1], -(a[2] - a[0] + a[3] - a[1])))
	else:
		print(max(a[2] - a[0], a[0] - a[2]) + max(a[3] - a[1], a[1] - a[3]) + 2)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	(x1, y1, x2, y2) = sep()
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
testcase(int(inp()))


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(max(y1, y2) - min(y1, y2))
	elif y1 == y2:
		print(max(x1, x2) - min(x1, x2))
	else:
		print(max(y1, y2) - min(y1, y2) + max(x1, x2) - min(x1, x2) + 2)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	xd = abs(x1 - x2)
	yd = abs(y1 - y2)
	if xd == 0:
		print(yd)
	elif yd == 0:
		print(xd)
	else:
		print(xd + yd + 2)


n = int(input())
a = []
for _ in range(n):
	x = input()
	a.append(x)
for ad in a:
	p = ad.split()
	if p[1] == p[3] or p[0] == p[2]:
		print(abs(int(p[2]) - int(p[0])) + abs(int(p[3]) - int(p[1])))
	else:
		print(abs(int(p[2]) - int(p[0])) + abs(int(p[3]) - int(p[1])) + 2)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=300006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if a == c and b == d:
		print(0)
	elif b == d:
		print(abs(c - a))
	elif c == a:
		print(abs(b - d))
	else:
		print(abs(a - c) + 2 + abs(b - d))


t = int(input())
result = 0
for i in range(t):
	xy = list(map(int, input().strip().split()))
	result = abs(xy[0] - xy[2]) + abs(xy[1] - xy[3])
	if xy[0] != xy[2] and xy[1] != xy[3]:
		result = result + 2
	print(result)


for j in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if a == c:
		print(abs(b - d))
	elif b == d:
		print(abs(a - c))
	else:
		print(abs(a - c) + abs(b - d) + 2)


for _ in range(int(input())):
	(temp, c) = (0, 0)
	(x1, y1, x2, y2) = map(int, input().split())
	total = 0
	if x1 == x2 and y1 == y2:
		print(total)
		continue
	if x1 == x2:
		total = abs(y1 - y2)
		print(total)
		continue
	if y1 == y2:
		total = abs(x1 - x2)
		print(total)
		continue
	total += abs(x1 - x2) + abs(y1 - y2) + 2
	print(total)
	continue


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split(' '))
	delx = abs(x2 - x1)
	dely = abs(y2 - y1)
	if delx == 0:
		print(dely)
	elif dely == 0:
		print(delx)
	else:
		print(delx + dely + 2)


for w in range(int(input())):
	(x1, y1, x2, y2) = tuple(map(int, input().split()))
	if x2 == x1:
		ans = abs(y2 - y1)
	elif y2 == y1:
		ans = abs(x2 - x1)
	else:
		ans = abs(x2 - x1) + abs(y2 - y1) + 2
	print(ans)


i = int(input())
for _ in range(i):
	(x1, y1, x2, y2) = map(int, input().split())
	xdiff = abs(x1 - x2)
	ydiff = abs(y1 - y2)
	if xdiff == 0:
		print(ydiff)
	elif ydiff == 0:
		print(xdiff)
	else:
		print(xdiff + ydiff + 2)


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(x1, y1, x2, y2) = inputnums()
	ans = 0
	if x1 == x2:
		print(abs(y1 - y2))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(x1 - x2) + 2 + abs(y1 - y2))


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
	t -= 1


import math

def main():
	t = int(input())
	while t > 0:
		(x1, y1, x2, y2) = map(int, input().split())
		if x1 == x2 or y1 == y2:
			print(abs(x1 - x2) + abs(y1 - y2))
		else:
			print(abs(x1 - x2) + abs(y1 - y2) + 2)
		t -= 1
main()


t = int(input())
for i in range(t):
	p = []
	(n, m, n1, m1) = input().strip().split(' ')
	(n, m, n1, m1) = [int(n), int(m), int(n1), int(m1)]
	k1 = abs(n1 - n)
	k2 = abs(m1 - m)
	if k1 and k2:
		k2 += 2
	print(k1 + k2)


import sys
a = sys.stdin.readline()
for i in range(0, int(a)):
	lis = sys.stdin.readline().split()
	for j in range(0, len(lis)):
		lis[j] = int(lis[j])
	if lis[0] != lis[2] and lis[1] != lis[3]:
		sys.stdout.write(str(2 + abs(lis[2] - lis[0]) + abs(lis[3] - lis[1])))
	else:
		sys.stdout.write(str(abs(lis[3] - lis[1]) + abs(lis[0] - lis[2])))
	sys.stdout.write('\n')


import math
import os
import random
import re
import sys

def solve():
	t = int(input())
	for _ in range(t):
		(x1, y1, x2, y2) = list(map(int, input().split()))
		distance = abs(x1 - x2) + abs(y1 - y2)
		if x1 != x2 and y1 != y2:
			distance += 2
		print(distance)
result = solve()


import sys

def solve(original_x: int, original_y: int, target_x: int, target_y: int) -> int:
	if original_x == target_x:
		return abs(original_y - target_y)
	if original_y == target_y:
		return abs(original_x - target_x)
	else:
		return abs(original_x - target_x) + abs(original_y - target_y) + 2
for (count, line) in enumerate(sys.stdin):
	if count == 0:
		continue
	(original_x, original_y, target_x, target_y) = [int(i) for i in line.split(' ')]
	print(solve(original_x, original_y, target_x, target_y))


def solve(x1, y1, x2, y2):
	if x1 == x2:
		return abs(y2 - y1)
	elif y2 == y1:
		return abs(x2 - x1)
	else:
		return abs(x2 - x1) + abs(y2 - y1) + 2
noOfTestCases = int(input())
for i in range(noOfTestCases):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = solve(x1, y1, x2, y2)
	print(ans)


def box_pull(arr):
	x1 = arr[0]
	y1 = arr[1]
	x2 = arr[2]
	y2 = arr[3]
	if x1 == x2:
		ans = abs(y2 - y1)
	elif y1 == y2:
		ans = abs(x2 - x1)
	else:
		ans = abs(x2 - x1) + abs(y2 - y1) + 2
	return ans
t = int(input())
for _ in range(t):
	arr = list(map(int, input().split()))
	print(box_pull(arr))


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	movex = x2 - x1
	movey = y2 - y1
	if not movex and (not movey):
		print(0)
	elif not movex and movey:
		print(abs(movey))
	elif not movey and movex:
		print(abs(movex))
	else:
		print(abs(movey) + abs(movex) + 2)


t = int(input())
answer = []
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split(' '))
	variable = abs(x2 - x1) + abs(y2 - y1) + 2 * (y2 - y1 != 0 and x2 - x1 != 0)
	answer.append(str(variable))
print('\n'.join(answer))


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	(x1, y1, x2, y2) = mi()
	if x1 == x2 or y1 == y2:
		print(abs(x1 - x2) + abs(y1 - y2))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	xdif = abs(x1 - x2)
	ydif = abs(y1 - y2)
	if xdif == 0 or ydif == 0:
		print(xdif + ydif)
	else:
		print(xdif + ydif + 2)


t = int(input())
for inx in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		dop = 0
	else:
		dop = 2
	print(abs(x1 - x2) + abs(y1 - y2) + dop)


def func():
	(x1, y1, x2, y2) = map(int, input().split())
	weight = abs(x1 - x2)
	height = abs(y1 - y2)
	if weight == 0:
		return height
	if height == 0:
		return weight
	return weight + height + 2
for i in range(int(input())):
	print(func())


n = int(input())
for i in range(n):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	time = 0
	if x2 - x1 == 0 or y2 - y1 == 0:
		time = abs(x1 - x2) + abs(y1 - y2)
	else:
		time = abs(x1 - x2) + abs(y1 - y2) + 2
	print(time)


t = input()
sol = []
for i in range(int(t)):
	(x1, y1, x2, y2) = input().split()
	x = abs(int(x2) - int(x1))
	y = abs(int(y2) - int(y1))
	if x == 0 or y == 0:
		rpta = x + y
	else:
		rpta = x + y + 2
	sol.append(rpta)
for j in sol:
	print(j)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(X1, Y1, X2, Y2) = [int(x) for x in input().split()]
		if X1 == X2:
			print(abs(Y2 - Y1))
			continue
		if Y1 == Y2:
			print(abs(X2 - X1))
			continue
		print(abs(X2 - X1) + abs(Y2 - Y1) + 2)
main()


while 1:
	t = int(input())
	if t >= 1 and t <= 1000:
		break
for i in range(t):
	L = list(map(int, input().split()))
	if L[0] == L[2]:
		print(abs(L[1] - L[3]))
	elif L[1] == L[3]:
		print(abs(L[0] - L[2]))
	else:
		print(2 + abs(L[0] - L[2]) + abs(L[1] - L[3]))


import math
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	a = abs(x1 - x2) + abs(y1 - y2)
	if x1 == x2 or y1 == y2:
		print(a)
	else:
		print(a + 2)


def dist(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())

	def solve():
		if x1 != x2 and y1 != y2:
			return dist(x1, y1, x2, y2) + 2
		elif x1 != x2:
			return abs(x1 - x2)
		elif y1 != y2:
			return abs(y1 - y2)
		else:
			return 0
	result = solve()
	print(result)


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		(X1, Y1, X2, Y2) = map(int, input().split())
		x = abs(X2 - X1)
		y = abs(Y2 - Y1)
		ans = x + y
		if x > 0 and y > 0:
			ans += 2
		print(ans)
main()


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = input().split()
	x1 = int(x1)
	y1 = int(y1)
	x2 = int(x2)
	y2 = int(y2)
	if x1 == x2 and y1 != y2:
		c = abs(y1 - y2)
	elif x1 != x2 and y1 == y2:
		c = abs(x1 - x2)
	elif x1 == x2 and y1 == y2:
		c = 0
	else:
		a = abs(x1 - x2)
		b = abs(y1 - y2)
		c = a + b + 2
	print(c)


def mp():
	return map(int, input().split())

def it():
	return int(input())
for _ in range(it()):
	(a, b, c, d) = mp()
	if abs(a - c) == 0 or abs(b - d) == 0:
		print(abs(a - c) + abs(b - d))
	else:
		print(abs(a - c) + abs(b - d) + 2)


def recal():
	(x, y, a, b) = map(int, input().split())
	f = abs(x - a)
	g = abs(y - b)
	print(2 * bool(f) * bool(g) + f + g)
t = int(input())
while t > 0:
	recal()
	t -= 1


for _ in range(int(input())):
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	if y1 == y2:
		print(max(x1, x2) - min(x1, x2))
		continue
	elif x1 == x2:
		print(max(y1, y2) - min(y1, y2))
		continue
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
		continue


n = int(input())
M = []
for i in range(n):
	L = list(map(int, input().split()))
	M.append(L)

def minimum(L):
	m = abs(L[0] - L[2]) + abs(L[1] - L[3])
	if L[0] != L[2] and L[1] != L[3]:
		m += 2
	return m
for i in range(len(M)):
	print(minimum(M[i]))


for _ in range(int(input())):
	(x, y, p, q) = map(int, input().split())
	if x == p or y == q:
		print(abs(x - p) + abs(q - y))
	else:
		print(abs(x - p) + abs(q - y) + 2)


t = int(input())

def solve(x1, y1, x2, y2):
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	if dx != 0 and dy != 0:
		return dx + dy + 2
	else:
		return max(dx, dy)
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	print(solve(a, b, c, d))


for _ in range(int(input())):
	(x, y, a, b) = map(int, input().split())
	xx = abs(x - a)
	yy = abs(y - b)
	print(xx + yy + 2 if xx > 0 and yy > 0 else xx + yy)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	coordinates = inlt()
	(x1, y1, x2, y2) = (coordinates[0], coordinates[1], coordinates[2], coordinates[3])
	increment = 2
	if x1 == x2 or y1 == y2:
		increment = 0
	result = abs(x1 - x2) + abs(y1 - y2) + increment
	print(result)


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = input().split()
	(x1, y1, x2, y2) = (int(x1), int(y1), int(x2), int(y2))
	xdiff = abs(x2 - x1)
	ydiff = abs(y2 - y1)
	if xdiff == 0 and ydiff == 0:
		print(0)
	elif xdiff == 0 or ydiff == 0:
		print(max(xdiff, ydiff))
	else:
		print(max(xdiff, ydiff) + min(xdiff, ydiff) - 1 + 3)


import sys
t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, sys.stdin.readline().split())
	q = abs(c - a) + abs(b - d)
	if abs(c - a) != 0 and abs(b - d) != 0:
		q = q + 2
	print(q)


t = int(input())
for i in range(t):
	l = [int(x) for x in input().split()]
	if len(l) == 4:
		if l[0] == l[2]:
			print(abs(l[1] - l[3]))
		elif l[1] == l[3]:
			print(abs(l[0] - l[2]))
		else:
			print(abs(l[0] - l[2]) + abs(l[1] - l[3]) + 2)


from math import *

def minStep(a):
	if a[0] == a[2] and a[1] == a[3]:
		return 0
	elif a[0] == a[2]:
		return int(fabs(a[1] - a[3]))
	elif a[1] == a[3]:
		return int(fabs(a[0] - a[2]))
	else:
		return int(fabs(a[0] - a[2])) + int(fabs(a[1] - a[3])) + 2
t = int(input())
for i in range(t):
	a = [int(x) for x in input().split()]
	print(minStep(a))


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		(x1, y1, x2, y2) = map(int, input().split())
		if x1 == x2 or y1 == y2:
			print(abs(x1 - x2) + abs(y1 - y2))
		else:
			print(abs(x1 - x2) + abs(y1 - y2) + 2)
main()


for i in range(int(input())):
	s = input().split()
	sum = abs(int(s[0]) - int(s[2])) + abs(int(s[1]) - int(s[3]))
	if int(s[0]) != int(s[2]) and int(s[1]) != int(s[3]):
		sum += 2
	print(sum)


for i in range(int(input())):
	(x, y, xb, yb) = map(int, input().split(' '))
	ans = 0
	if x == xb or y == yb:
		if x == xb:
			print(abs(yb - y))
		else:
			print(abs(xb - x))
	else:
		print(abs(xb - x) + 2 + abs(yb - y))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(x1, y1, x2, y2) = ria()
		t = abs(x2 - x1) + abs(y2 - y1)
		if x1 != x2 and y1 != y2:
			t += 2
		print(t)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


s = open(0).readlines()
a = []
for inp in s[1:]:
	(x1, y1, x2, y2) = map(int, inp.split())
	a.append(abs(x1 - x2) + abs(y1 - y2) + (0 if x1 == x2 or y1 == y2 else 2))
print(*a, sep='\n')


t = int(input())
for o in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	a = abs(x2 - x1)
	b = abs(y2 - y1)
	c = 2 + a + b
	if x1 != x2 and y2 != y1:
		print(c)
	else:
		print(c - 2)


for _ in range(int(input())):
	a = input().split(' ')
	if int(a[0]) < int(a[2]):
		(x1, x2) = (int(a[0]), int(a[2]))
	else:
		(x2, x1) = (int(a[0]), int(a[2]))
	if int(a[1]) < int(a[3]):
		(y1, y2) = (int(a[1]), int(a[3]))
	else:
		(y2, y1) = (int(a[1]), int(a[3]))
	itg = x2 - x1
	if y2 != y1 and x2 != x1:
		itg += 2
	itg += y2 - y1
	print(itg)


n = int(input())
for _ in range(n):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	k1 = abs(x1 - x2)
	k2 = abs(y1 - y2)
	if k1 == 0:
		print(k2)
	elif k2 == 0:
		print(k1)
	else:
		print(k1 + k2 + 2)


def ques1(x1, y1, x2, y2):
	if x1 == x2:
		return abs(y2 - y1)
	if y1 == y2:
		return abs(x2 - x1)
	return abs(y2 - y1) + abs(x2 - x1) + 2
t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	ans = ques1(x1, y1, x2, y2)
	print(ans)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solution():
	t = inp()
	for _ in range(t):
		(x1, y1, x2, y2) = inlt()
		print(solve(x1, y1, x2, y2))

def solve(x1, y1, x2, y2):
	dx = abs(x2 - x1)
	dy = abs(y2 - y1)
	return dx + dy + 2 - 2 * (dx == 0 or dy == 0)
solution()


def fun(a, b, x, y):
	if a == x:
		return abs(y - b)
	elif b == y:
		return abs(x - a)
	else:
		return abs(y - b) + abs(x - a) + 2
total = int(input())
for index in range(total):
	c = [int(x) for x in input().split()]
	result = fun(c[0], c[1], c[2], c[3])
	print(result)


from sys import stdin
t = int(stdin.readline())
for cs in range(t):
	(x1, y1, x2, y2) = list(map(int, stdin.readline().split(' ')))
	dis = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		dis += 2
	print(dis)


for _ in range(int(input())):
	(x, y, z, t) = map(int, input().split())
	a = abs(x - z) + abs(y - t)
	if x != z and y != t:
		a += 2
	print(a)


import math
t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	temp = abs(x2 - x1) + abs(y2 - y1)
	if x1 != x2 and y1 != y2:
		print(temp + 2)
	else:
		print(temp)


def rl():
	return list(map(int, input().split()))

def arp(arr):
	return ' '.join([str(i) for i in arr])
from collections import deque, Counter
from math import ceil, sqrt, log2, log, floor
for _ in range(int(input())):
	(x, y, x1, y1) = rl()
	if x == x1:
		print(abs(y - y1))
	elif y == y1:
		print(abs(x - x1))
	else:
		print(abs(x - x1) + abs(y - y1) + 2)


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	x = abs(x2 - x1)
	y = abs(y2 - y1)
	if x1 != x2 and y1 != y2:
		x += 2
	print(x + y)


from sys import stdin
import sys
tt = int(stdin.readline())
for loop in range(tt):
	(x, y, X, Y) = map(int, stdin.readline().split())
	if x == X or y == Y:
		print(abs(x - X) + abs(y - Y))
	else:
		print(abs(x - X) + abs(y - Y) + 2)


x = int(input())
for i in range(x):
	ans = 0
	(a, b, c, d) = map(int, input().split())
	if a == c and b == d:
		print(ans)
		continue
	if a != c and b != d:
		ans += 2
	ans += abs(a - c)
	ans += abs(b - d)
	print(ans)


import sys
from math import gcd, sqrt, ceil, log2
from collections import defaultdict, Counter, deque
from bisect import bisect_left, bisect_right
import math
from itertools import permutations
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def get_sum(bit, i):
	s = 0
	i += 1
	while i > 0:
		s += bit[i]
		i -= i & -i
	return s

def update(bit, n, i, v):
	i += 1
	while i <= n:
		bit[i] += v
		i += i & -i

def modInverse(b, m):
	g = math.gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def primeFactors(n):
	sa = set()
	sa.add(n)
	while n % 2 == 0:
		sa.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			sa.add(i)
			n = n // i
	return sa

def seive(n):
	pri = [True] * (n + 1)
	p = 2
	while p * p <= n:
		if pri[p] == True:
			for i in range(p * p, n + 1, p):
				pri[i] = False
		p += 1
	return pri

def check_prim(n):
	if n < 0:
		return False
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def debug(l, r):
	maxi = -1
	ans = -1
	for i in range(l, r + 1):
		z = bin(i).count('1')
		if z > maxi:
			maxi = z
			ans = i
	return ans
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x1 - x2))
	else:
		print(abs(y2 - y1) + abs(x1 - x2) + 2)


t = int(input().rstrip())
while t > 0:
	t -= 1
	(x1, y1, x2, y2) = map(int, input().strip().split())
	ans = 0
	if y1 == y2 or x1 == x2:
		ans = abs(x1 - x2) + abs(y1 - y2)
	else:
		ans = abs(x1 - x2) + abs(y1 - y2) + 2
	print(ans)


t = int(input())
for case in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	dx = abs(x2 - x1)
	dy = abs(y2 - y1)
	tot = dx + dy
	if dx and dy:
		tot += 2
	if dx == 0 and dy == 0:
		print(0)
	else:
		print(tot)


from collections import Counter

def func():
	(x, y, a, b) = map(int, input().split())
	c = abs(x - a) + abs(y - b)
	if x != a and y != b:
		c += 2
	print(c)
t = 1
t = int(input())
for i in range(t):
	func()


from sys import stdin

def main(x1, y1, x2, y2):
	time = abs(x1 - x2) + abs(y1 - y2)
	if not (x1 == x2 or y1 == y2):
		time += 2
	print(time)
t = int(stdin.readline())
cases = [[int(s) for s in stdin.readline().split()] for _ in range(t)]
for (x1, y1, x2, y2) in cases:
	main(x1, y1, x2, y2)


for i in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	c = abs(y2 - y1)
	d = abs(x2 - x1)
	if c == 0 or d == 0:
		print(d + c)
	else:
		print(c + d + 2)


n = int(input())
for i in range(n):
	(x1, y1, x2, y2) = map(int, input().split())
	add = 0
	if x1 != x2:
		add += 1
	if y1 != y2:
		add += 1
	ans = abs(x1 - x2) + abs(y1 - y2)
	if add == 2:
		ans += 2
	print(ans)


def solve():
	(a, b, c, d) = map(int, input().split())
	ans = abs(a - c) + abs(b - d)
	if a != c and b != d:
		ans += 2
	print(ans)

def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		solve()
	return 0
main()


t = int(input())
answers = []
for _ in range(t):
	coordinates = input().split()
	if int(coordinates[0]) == int(coordinates[2]):
		x = abs(int(coordinates[3]) - int(coordinates[1]))
	elif int(coordinates[1]) == int(coordinates[3]):
		x = abs(int(coordinates[2]) - int(coordinates[0]))
	else:
		x = abs(int(coordinates[3]) - int(coordinates[1])) + abs(int(coordinates[2]) - int(coordinates[0])) + 2
	answers.append(x)
for j in range(t):
	print(answers[j])


t = int(input())
for i in range(0, t):
	L = list(map(int, input().split()))
	a = abs(L[0] - L[2])
	b = abs(L[1] - L[3])
	if min(a, b) == 0:
		print(a + b)
	else:
		print(a + b + 2)


t = int(input())
for test in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 or y1 == y2:
		print(max(abs(x1 - x2), abs(y1 - y2)))
	else:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split(' '))
	xdist = abs(x2 - x1)
	ydist = abs(y2 - y1)
	if x1 == x2 or y1 == y2:
		print(xdist + ydist)
	else:
		print(xdist + ydist + 2)


t = int(input())
for t1 in range(0, t):
	(x1, y1, x2, y2) = map(int, input().split())
	z = abs(x1 - x2) + abs(y1 - y2)
	if x1 != x2 and y1 != y2:
		z += 2
	print(z)


from sys import stdin, stdout
from math import gcd
input = stdin.readline
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if a == c or b == d:
		print(abs(a - c) + abs(b - d))
	else:
		print(abs(a - c) + abs(b - d) + 2)


n = int(input())
for i in range(n):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	diff = abs(x2 - x1) + abs(y2 - y1)
	if x1 == x2 and y1 == y2:
		print(0)
	elif diff == 1:
		print(abs(diff))
	elif x1 == x2 or y1 == y2:
		print(abs(diff))
	else:
		print(abs(diff) + 2)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(x1, y1, x2, y2) = mints()
	print(abs(x1 - x2) + abs(y1 - y2) + 2 * (x1 - x2 != 0 and y1 - y2 != 0))
for i in range(mint()):
	solve()


t = int(input())
res = []
for x in range(t):
	cad = input().split()
	arr = []
	for c in cad:
		arr.append(int(c))
	res.append(arr)
for caso in res:
	nCeros = abs(caso[2] - caso[0])
	nUnos = abs(caso[3] - caso[1])
	nSegundos = 0
	if nCeros == 0 or nUnos == 0:
		nSegundos += nCeros + nUnos
	else:
		nSegundos += nCeros + nUnos + 2
	print(nSegundos)


t = int(input())
for tt in range(t):
	(xs, ys, xf, yf) = map(int, input().split())
	ans = max(abs(xs - xf), abs(ys - yf))
	if min(abs(xs - xf), abs(ys - yf)) != 0:
		ans += 2 + min(abs(xs - xf), abs(ys - yf))
	print(ans)


try:
	t = 0
	t = int(input())
	while t:
		(x1, y1, x2, y2) = map(int, input().split())
		if x1 == x2 and y1 == y2:
			print('0')
		elif y1 == y2:
			print(abs(x1 - x2))
		elif x1 == x2:
			print(abs(y1 - y2))
		elif y1 != y2:
			(temp1, temp2) = (0, 0)
			if abs(y1 - y2) > abs(x1 - x2):
				temp1 = abs(x1 - x2)
				temp2 = abs(y1 - y2)
			else:
				temp1 = abs(y1 - y2)
				temp2 = abs(x1 - x2)
			temp1 += temp2 + 2
			print(temp1)
		t -= 1
except:
	pass


import sys
from sys import maxsize

def inputint():
	return map(int, sys.stdin.readline().strip().split())

def inputlist():
	return list(map(int, sys.stdin.readline().strip().split()))

def inputstr():
	return list(sys.stdin.readline().strip().split())
for i in range(int(sys.stdin.readline())):
	(x1, y1, x2, y2) = inputint()
	s = 0
	s = abs(x1 - x2) + abs(y1 - y2)
	if x1 == x2 or y1 == y2:
		print(s)
	else:
		print(s + 2)


T = int(input())
for _ in range(T):
	(x1, y1, x2, y2) = map(int, input().split())
	(xdiff, ydiff) = (abs(x2 - x1), abs(y2 - y1))
	C = xdiff + ydiff
	C += 2 * int(int(xdiff > 0) + int(ydiff > 0) > 1)
	print(C)


import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)

def put():
	return map(int, stdin.readline().split())
for _ in range(int(input())):
	(x1, y1, x2, y2) = put()
	if x1 == x2:
		print(abs(y2 - y1))
	elif y1 == y2:
		print(abs(x2 - x1))
	else:
		print(abs(y2 - y1) + abs(x2 - x1) + 2)


N = int(input())
for i in range(N):
	(sx, sy, gx, gy) = map(int, input().split())
	ans = abs(sx - gx) + abs(sy - gy)
	if sx == gx or sy == gy:
		print(ans)
		continue
	ans += 2
	print(ans)


from sys import stdin

def input():
	return stdin.readline().rstrip()
for i in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	xdif = abs(x2 - x1)
	ydif = abs(y2 - y1)
	res = 0
	if xdif != 0 and ydif != 0:
		res = 2
	print(res + ydif + xdif)


def solve():
	(x1, y1, x2, y2) = map(int, input().split())
	t = 0
	ans = 0
	if x1 != x2:
		ans += abs(x1 - x2)
		t += 1
	if y1 != y2:
		ans += abs(y1 - y2)
		t += 1
	print(ans + max(t - 1, 0) * 2)
for i in range(int(input())):
	solve()


import math

def process():
	(x1, y1, x2, y2) = list(map(int, input().split()))
	x = abs(x1 - x2)
	y = abs(y1 - y2)
	if x != 0 and y != 0:
		return x + y + 2
	else:
		return x + y
tests = int(input())
for i in range(tests):
	print(process())


n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	if l[0] > l[2]:
		(l[0], l[2]) = (l[2], l[0])
	if l[1] > l[3]:
		(l[1], l[3]) = (l[3], l[1])
	if l[0] != l[2] and l[1] != l[3]:
		l[2] += 1
		x = l[2] - l[0]
		if x < 0:
			x = -x
		y = l[3] - l[1]
		if y < 0:
			y = -y
		x += 1
		x += y
	else:
		x = l[2] - l[0] + (l[3] - l[1])
	if x < 0:
		print(-x)
	else:
		print(x)


N = int(input())
for i in range(0, N):
	(A, B, C, D) = list(map(int, input().split()))
	if B != D and A != C:
		print(abs(A - C) + abs(B - D) + 2)
	else:
		print(abs(A - C) + abs(B - D))


def solve(x1, y1, x2, y2):
	if x1 != x2 and y1 != y2:
		return abs(x1 - x2) + abs(y1 - y2) + 2
	else:
		return abs(x1 - x2) + abs(y1 - y2)
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	print(solve(x1, y1, x2, y2))


for i1 in range(int(input())):
	(x1, y1, x2, y2) = [int(i) for i in input().split()]
	ans = abs(x2 - x1) + abs(y2 - y1)
	if y1 != y2 and x1 != x2:
		ans += 2
	print(ans)


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	(x1, y1, x2, y2) = idata()
	if abs(x1 - x2) > 0 and abs(y1 - y2) > 0:
		print(abs(y2 - y1) + abs(x1 - x2) + 2)
	else:
		print(abs(x1 - x2) + abs(y1 - y2))
	return
for t in range(int(ii())):
	solve()


import sys
t = int(sys.stdin.readline().strip())
for i in range(t):
	(a, b, c, d) = map(int, sys.stdin.readline().split())
	if a == c:
		print(abs(b - d))
	elif b == d:
		print(abs(a - c))
	else:
		print(abs(a - c) + abs(b - d) + 2)


from math import *
from collections import deque
from copy import deepcopy
import sys

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def multi():
	return map(int, input().split())

def strmulti():
	return map(str, inp().split())

def lis():
	return list(map(int, inp().split()))

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def stringlis():
	return list(map(str, inp().split()))

def out(var):
	sys.stdout.write(str(var))

def printlist(a):
	print(' '.join((str(a[i]) for i in range(len(a)))))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = multi()
	if x1 != x2 and y1 != y2:
		print(abs(x1 - x2) + abs(y1 - y2) + 2)
		continue
	print(abs(x1 - x2) + abs(y1 - y2))


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if y1 == y2:
		print(abs(x1 - x2))
		continue
	if x1 == x2:
		print(abs(y1 - y2))
		continue
	dist = abs(x2 - x1) + abs(y1 - y2)
	print(dist + 2)


for _ in range(int(input())):
	(a, b, a0, b0) = map(int, input().split())
	res = abs(a - a0) + abs(b - b0)
	if b != b0 and a != a0:
		res += 2
	print(res)


cases = int(input())
for _ in range(cases):
	ds = list(map(int, input().split()))
	if ds[0] == ds[2]:
		print(abs(ds[3] - ds[1]))
	elif ds[1] == ds[3]:
		print(abs(ds[0] - ds[2]))
	else:
		print(abs(ds[0] - ds[2]) + abs(ds[1] - ds[3]) + 2)


T = int(input())
for t in range(T):
	(x1, y1, x2, y2) = [int(_) for _ in input().split()]
	if x1 == x2 or y1 == y2:
		print(abs(x2 - x1) + abs(y2 - y1))
	else:
		print(abs(x2 - x1) + abs(y2 - y1) + 2)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	if abs(x2 - x1) == 0:
		print(abs(y2 - y1))
	elif abs(y2 - y1) == 0:
		print(abs(x2 - x1))
	else:
		print(abs(x2 - x1) + 1 + abs(y2 - y1) + 1)


val = input()
for i in range(int(val)):
	(x1, y1, x2, y2) = str.split(input())
	if (int(x1) - int(x2) == 0) | (int(y1) - int(y2) == 0):
		print(abs(int(x1) - int(x2)) + abs(int(y1) - int(y2)))
	else:
		print(abs(int(x1) - int(x2)) + abs(int(y1) - int(y2)) + 2)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c for j in range(b)] for i in range(a)]

def list3d(a, b, c, d):
	return [[[d for k in range(c)] for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
for _ in range(INT()):
	(x1, y1, x2, y2) = MAP()
	if x1 == x2 or y1 == y2:
		ans = abs(x1 - x2) + abs(y1 - y2)
	else:
		ans = abs(x1 - x2) + abs(y1 - y2) + 2
	print(ans)


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split(' '))
	diff_x = abs(x1 - x2)
	diff_y = abs(y1 - y2)
	if diff_x == 0 or diff_y == 0:
		print(max(diff_y, diff_x))
	else:
		print(diff_x + diff_y + 2)


from sys import stdin, stdout
n = int(stdin.readline())
for i in range(n):
	(x1, y1, x2, y2) = map(int, stdin.readline().split())
	nostep = 0
	nostep = abs(x2 - x1) + abs(y2 - y1)
	if x1 != x2 and y1 != y2:
		nostep += 2
	print(nostep)


q = int(input())
for i in range(q):
	(xa, ya, xb, yb) = map(int, input().split())
	xd = xa - xb
	if xd < 0:
		xd *= -1
	yd = ya - yb
	if yd < 0:
		yd *= -1
	if ya == yb:
		print(xd)
		continue
	if xa == xb:
		print(yd)
		continue
	print(xd + 2 + yd)


import sys, math
input = sys.stdin.readline
t = int(input())
for r in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	ans = 0
	if x1 == x2 or y1 == y2:
		ans = abs(x1 - x2) + abs(y1 - y2)
	else:
		ans = abs(x1 - x2) + abs(y1 - y2) + 2
	print(ans)


def isBalanced(arr):
	if int(arr[2]) == int(arr[0]) or int(arr[1]) == int(arr[3]):
		a = abs(int(arr[2]) - int(arr[0])) + abs(int(arr[3]) - int(arr[1]))
	else:
		a = abs(int(arr[2]) - int(arr[0])) + abs(int(arr[3]) - int(arr[1])) + 2
	return a
for i in range(int(input())):
	print(isBalanced(input().strip().split()))


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '2\n1 2 2 2\n1 1 2 2\n\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield sys.stdin.readline()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def tuplerize(method):

	def wrap(*args, **kwargs):
		res = method(*args, **kwargs)
		if not isinstance(res, (tuple, list)):
			res = (res,)
		return res
	return wrap

def binary_pow(a, b):
	result = 1
	while b:
		if b % 1:
			result *= a
		a *= a
		b >>= 1
	return result

@tuplerize
def solve(a):
	pass
t = getType(int)
for _ in range(t):
	(x1, y1, x2, y2) = getArray(int)
	horiz = abs(x1 - x2)
	vertic = abs(y1 - y2)
	add = 0
	if horiz != 0 and vertic != 0:
		add = 2
	print(horiz + vertic + add)


n = int(input())
for i in range(n):
	a = [int(i) for i in input().split()]
	total = 0
	if abs(a[2] - a[0]) == 0:
		total = total + abs(a[1] - a[3])
	elif abs(a[1] - a[3]) == 0:
		total = total + abs(a[2] - a[0])
	else:
		total = total + abs(a[2] - a[0]) + 1
		total = total + abs(a[1] - a[3]) + 1
	print(total)


m = int(input())
l = []
for i in range(m):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 == x2 and y1 == y2:
		l.append(0)
	elif x1 == x2 or y1 == y2:
		if x1 != x2:
			l.append(abs(x1 - x2))
		else:
			l.append(abs(y1 - y2))
	else:
		l.append(abs(x1 - x2) + abs(y1 - y2) + 2)
for i in l:
	print(i)


t = int(input())
for case in range(t):
	X = [int(s) for s in input().split(' ')]
	left = abs(X[0] - X[2])
	up = abs(X[1] - X[3])
	ans = left + up
	if min(left, up) > 0:
		ans += 2
	print(ans)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	X = abs(x1 - x2)
	Y = abs(y1 - y2)
	if X == 0 or Y == 0:
		print(X + Y)
	else:
		print(X + Y + 2)


T = int(input())
for i in range(0, T):
	(x_1, y_1, x_2, y_2) = input().split()
	x_1 = int(x_1)
	y_1 = int(y_1)
	x_2 = int(x_2)
	y_2 = int(y_2)
	ans = abs(x_1 - x_2) + abs(y_1 - y_2)
	if x_1 != x_2:
		if y_1 != y_2:
			ans += 2
	print(ans)


for i in range(int(input())):
	(xa, ya, xb, yb) = map(int, input().split())
	if xb == xa or yb == ya:
		print(max(abs(xb - xa), abs(yb - ya)))
	else:
		print(2 + abs(xb - xa) + abs(yb - ya))


from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	(x, y, c, d) = M()
	a = abs(c - x)
	b = abs(d - y)
	(a, b) = (max(a, b), min(a, b))
	ans = 0
	ans += a
	if b > 0:
		ans += 2
		ans += b
	print(ans)


import sys
import os
t = int(input().strip())
for T in range(t):
	(a, b, c, d) = input().strip().split()
	(a, b, c, d) = (int(a), int(b), int(c), int(d))
	ans = abs(a - c) + abs(b - d)
	if a == c or b == d:
		pass
	else:
		ans += 2
	print(ans)


for t in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	print(min(abs(x1 - x2) + abs(y1 - y2) + (2 if abs(y1 - y2) != 0 else 0), abs(x1 - x2) + abs(y1 - y2) + (2 if abs(x1 - x2) != 0 else 0)))


for _ in range(int(input())):
	inputs = list(map(int, input().split()))
	(x1, y1, x2, y2) = inputs
	if x1 == x2 or y1 == y2:
		sum = abs(x1 - x2) + abs(y1 - y2)
	else:
		sum = abs(x1 - x2) + abs(y1 - y2) + 2
	print(sum)


t = int(input())
while t:
	t -= 1
	(x1, y1, x2, y2) = map(int, input().split())
	nx = abs(x1 - x2)
	ny = abs(y1 - y2)
	if nx == 0 or ny == 0:
		print(nx + ny)
	elif nx == 0 and ny == 0:
		print(0)
	else:
		print(nx + ny + 2)


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
t = ri()
for _ in range(t):
	(x1, y1, x2, y2) = ris()
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	ans = dx + dy
	if x1 != x2 and y1 != y2:
		ans += 2
	print(ans)


ns = lambda : input()
ni = lambda : int(input())
nm = lambda : map(int, input().split())
nl = lambda : list(map(int, input().split()))
for _ in range(ni()):
	(x1, y1, x2, y2) = nm()
	dx = abs(x1 - x2)
	dy = abs(y1 - y2)
	if dx != 0 and dy != 0:
		print(dx + dy + 2)
		continue
	print(dx + dy)


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	d = abs(x2 - x1) + abs(y2 - y1)
	if x2 - x1 == 0 or y2 - y1 == 0:
		time = d
	else:
		time = d + 2
	print(time)


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	x = max(abs(x1 - x2), abs(y1 - y2))
	if x1 == x2 or y1 == y2:
		print(x)
	else:
		ans = x + min(abs(x1 - x2), abs(y1 - y2)) + 2
		print(ans)


n = int(input())
while n > 0:
	n -= 1
	(x, y, z, t) = map(int, input().split(' '))
	sum = abs(x - z) + abs(y - t)
	if x != z and y != t:
		sum += 2
	print(sum)


from math import *
t = int(input())
while t:
	t = t - 1
	(x1, y1, x2, y2) = map(int, input().split())
	x = abs(x2 - x1)
	y = abs(y2 - y1)
	ans = x + y
	if x != 0 and y != 0:
		ans += 2
	print(ans)


t = int(input())
for _ in range(t):
	(a, b, c, d) = [int(x) for x in input().split()]
	ret = abs(a - c) + abs(b - d)
	if a != c and b != d:
		ret += 2
	print(ret)