Little Rohu from Pluto is the best bomb defusor on the entire planet. She has saved the planet from getting destruced multiple times now. Of course, she's proud of her achievments. But, to prepare herself for more complicated situations, she keeps challenging herself to handle tricky tasks.
Her current challenge involves the following things:
- A square matrix of the form N*N.  
- B bombs planted at various cells of the square matrix.
- There can be multiple bombs at a given cell. 
- Only the four corners of the square matrix have a bomb defusor, so if a bomb is moved to any one of the four corners, it will be defused.

From a given cell, any bomb can be moved in all the four directions, North, South, East, West respectively.

Rohu is given the number of bombs and the dimensions of the square matrix she's going to be dealing with, you've to help her figure out the minimum number of moves required to defuse all the bombs.

Note-1: She's not going to enter the matrix, she's just going to move the bombs from outside. 
Note-2: The matrix is 1-indexed. 

-----Input-----
- The first line of each test case contains two integers N, denoting the dimension of the square matrix, and B denoting the number of bombs. This will be followed by two lines, where the first line will denote the x-coordinate of all the bombs, and the second line will denote the y-coordinate of all the bombs. x[0], y[0] will be the position of the first bomb, ... , x[B-1], y[B-1] will be the position of the Bth bomb.

-----Output-----
- Output a single line containing the minimum number of moves required.

-----Subtasks-----
- 1 ≤ N, B ≤ 100000: 50 points

- 1 ≤ N, B ≤ 1000: 30 points

- 1 ≤ N, B ≤ 10: 20 points

-----Constraints-----
- 1 ≤ N, B ≤ 100000

-----Example 1-----
Input:
3 3
1 2 3
3 2 1

Output:
2

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

Output:
0

-----Explanation-----
Example case 1:Only the bomb at {2,2} needs to be moved in two steps.
Example case 2:No bomb needs to be moved anywhere.

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
(n, b) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = 0
for i in range(b):
	ans += min(x[i] - 1, n - x[i]) + min(y[i] - 1, n - y[i])
print(ans)


(n, b) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
(x1, y1) = (1, 1)
(x2, y2) = (n, 1)
(x3, y3) = (1, n)
(x4, y4) = (n, n)
c = 0
for i in range(0, b):
	c = c + min(abs(x[i] - x1) + abs(y[i] - y1), abs(x[i] - x2) + abs(y[i] - y2), abs(x[i] - x3) + abs(y[i] - y3), abs(x[i] - x4) + abs(y[i] - y4))
print(c)


(a, b) = list(map(int, input().split()))
c = list(map(int, input().split()))
d = list(map(int, input().split()))
ans = 0
for i in range(0, b):
	c[i] = c[i] - 1
	d[i] = d[i] - 1
	f = []
	f.append(c[i] + d[i])
	f.append(2 * a - 2 - c[i] - d[i])
	f.append(a - 1 - c[i] + d[i])
	f.append(c[i] + a - 1 - d[i])
	ans = ans + min(f)
print(ans)


def f(n, b):
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	count = 0
	diff = [(1, n), (n, 1), (n, n), (1, 1)]
	for i in range(b):
		m = 9999999
		for j in diff:
			a = abs(x[i] - j[0]) + abs(y[i] - j[1])
			m = min(m, a)
		count += m
	return count
(n, b) = list(map(int, input().split()))
print(f(n, b))


def rawInput():
	return [int(x) for x in input().split()]
(n, b) = rawInput()
x = rawInput()
y = rawInput()

def compute(a, b):
	dis = abs(1 - a) + abs(1 - b)
	dis = min(dis, abs(1 - a) + abs(n - b))
	dis = min(dis, abs(n - a) + abs(n - b))
	dis = min(dis, abs(n - a) + abs(1 - b))
	return dis
rlt = 0
for i in range(b):
	rlt = rlt + compute(x[i], y[i])
print(rlt)


(n, b) = list(map(int, input().strip().split()))
lx = list(map(int, input().strip().split()))
ly = list(map(int, input().strip().split()))
x = 0
for i in range(0, b):
	x += min(n - lx[i], lx[i] - 1)
	x += min(n - ly[i], ly[i] - 1)
print(x)