A city has been infected by a contagious virus.

In a survey, it was found that A out of the N people living in the city are currently infected.
It has been observed that the only way for a person to get infected is if he comes in contact with an already infected person, and both of them are NOT wearing a mask.

The mayor of the city wants to make a new Mask Policy and find out the minimum number of people that will be required to wear a mask to avoid the further spread of the virus.
Help the mayor in finding this number.

Note: The only aim of the mayor is to stop virus spread, not to mask every infected person.

------ Input Format ------ 

- The first line contains T - number of test cases. Then the test cases follow.
- The first and only line of each test case contains two integers N and A - the total number of people living in the city and the number of people already affected by the virus respectively.

------ Output Format ------ 

For each test case, output the minimum number of people that will be required to wear a mask so as to curb the virus spread.

------ Constraints ------ 

$1 ≤ T ≤ 10^{5}$
$2 ≤ N ≤ 400$
$1 ≤ A < N$

----- Sample Input 1 ------ 
3
2 1
3 2
3 1
----- Sample Output 1 ------ 
1
1
1
----- explanation 1 ------ 
Test Case #1: There is $1$ infected person and $1$ uninfected person. We can ask any of them to wear a mask, and no more infections will occur. Hence the answer is $1$.

Test Case #2: There are $2$ infected people and $1$ uninfected person. We can ask the uninfected person to wear a mask, and no more infections will occur. Hence the answer is $1$.

Test Case #3: There is $1$ infected person and $2$ uninfected people. We can ask the single infected person to wear a mask, and no more infections will occur. Hence the answer is $1$.

Difficulty: EASY

Starter code:

Solutions:
for t in range(int(input())):
	(a, b) = map(int, input().split())
	c = a - b
	print(min(b, c))


t = int(input())
for i in range(t):
	(N, A) = map(int, input().split())
	if N - A <= A:
		print(N - A)
	else:
		print(A)


for i in range(int(input())):
	(n, a) = map(int, input().split())
	h = n - a
	print(min(h, a))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	a = x - y
	print(min(a, y))


for _ in range(int(input())):
	(n, a) = map(int, input().split())
	b = n - a
	if b >= a:
		print(a)
	else:
		print(b)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	print(min(b, abs(b - a)))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(min(a - b, b))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	c = a - b
	if c == b:
		print(b)
	elif c > b:
		print(b)
	else:
		print(c)


for i in range(int(input())):
	(n, i) = map(int, input().split())
	ni = n - i
	if i >= ni:
		print(ni)
	else:
		print(i)


t = int(input())
for i in range(t):
	(n, a) = list(map(int, input().split()))
	b = n - a
	ans = a
	if a > b:
		ans = b
	print(ans)


cases = int(input())
for _ in range(cases):
	(n, a) = map(int, input().split())
	res = n - a
	print(min(res, a))


for i in range(int(input())):
	(n, a) = map(int, input().split())
	k = n - a
	if k <= a:
		print(k)
	else:
		print(a)


t = int(input())
for i in range(t):
	(n, a) = map(int, input().split())
	b = n - a
	print(min(a, b))


for i in range(int(input())):
	(m, x) = map(int, input().split())
	print(min(m - x, x))


for t in range(int(input())):
	(tot_ppl, affected_ppl) = map(int, input().split())
	p = tot_ppl - affected_ppl
	if p > affected_ppl:
		print(affected_ppl)
		pass
	else:
		print(p)
		pass
	pass


t = int(input())
for bunny in range(t):
	(n, a) = map(int, input().split())
	print(min(n - a, a))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	print(min((x - y, y)))


for i in range(0, int(input())):
	list1 = list(map(int, input().split()))
	uninfected = list1[0] - list1[1]
	if list1[1] > uninfected:
		print(uninfected)
	else:
		print(list1[1])


t = int(input())
for i in range(t):
	x = list(input().split())
	n = int(x[0])
	a = int(x[1])
	a1 = int(n - a)
	if a <= a1:
		print(a)
	else:
		print(n - a)


for _ in range(int(input())):
	(n, a) = map(int, input().split())
	m = min(a, n - a)
	print(m)


for i in range(int(input())):
	n = list(map(int, input().split()))
	a = n[0]
	b = n[1]
	if a - b < b:
		print(a - b)
	else:
		print(b)


for t in range(int(input())):
	(a, b) = map(int, input().split())
	v = abs(a - b)
	if b >= v:
		print(v)
	else:
		print(b)


for i in range(int(input())):
	x = list(map(int, input().split()))
	c = x[1]
	b = x[0] - x[1]
	if c < b:
		print(c)
	else:
		print(b)


for _ in range(int(input())):
	(n, a) = map(int, input().split())
	infected = a
	uninfected = n - a
	if infected > uninfected:
		print(uninfected)
	else:
		print(infected)


T = int(input())
for i in range(T):
	(N, A) = map(int, input().split())
	print(min(N - A, A))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	x = abs(b - a)
	print(min(x, b))


T = int(input())
for i in range(T):
	(N, infected) = map(int, input().split())
	not_infected = N - infected
	no_of_masks = min(infected, not_infected)
	print(no_of_masks)


t = int(input())
for i in range(t):
	(t, p) = map(int, input().split())
	if t - p < p:
		print(t - p)
	else:
		print(p)


t = int(input())
for x in range(t):
	a = [int(c) for c in input().split()]
	print(min(a[0] - a[1], a[1]))


for _ in range(int(input())):
	(N, A) = map(int, input().split())
	U = N - A
	print(min(U, A))


for _ in range(int(input())):
	(people, inf) = map(int, input().split())
	remaining = people - inf
	if inf <= remaining:
		print(inf)
	else:
		print(remaining)


t = int(input())
for _ in range(t):
	line = input()
	words = line.split()
	n = int(words[0])
	a = int(words[1])
	s = n - a
	print(min(s, a))


t = int(input())
for _ in range(t):
	line = input()
	words = line.split()
	n = int(words[0])
	a = int(words[1])
	s = n - a
	if a > s:
		print(s)
	else:
		print(a)


t = int(input())
while t > 0:
	(n, inf) = map(int, input().split())
	m = inf
	if n - inf < m:
		m = n - inf
	print(m)
	t = t - 1


for T in range(int(input())):
	(n, a) = map(int, input().split())
	print(min(a, n - a))


t = int(input())
for i in range(t):
	[n, a] = list(map(int, input().split()))
	if a <= n - a:
		print(a)
	else:
		print(n - a)


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	c = A - B
	print(min(c, B))


t = int(input())
for _ in range(t):
	(total_numb, a) = map(int, input().split())
	unaffec = total_numb - a
	print(min(unaffec, a))


t = int(input())
for i in range(t):
	(A, N) = map(int, input().split())
	cond = A - N
	print(min(cond, N))