Chef's professor is planning to give his class a group assignment. There are 2N students in the class, with distinct roll numbers ranging from 1 to 2N. Chef's roll number is X.

The professor decided to create N groups of 2 students each. The groups were created as follows: the first group consists of roll numbers 1 and 2N, the second group of roll numbers 2 and 2N - 1, and so on, with the final group consisting of roll numbers N and N+1.

Chef wonders who his partner will be. Can you help Chef by telling him the roll number of his partner?

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

- The first line of input will contain an integer T — the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains two integers N and X, denoting the number of groups that will be formed, and Chef's roll number. 

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

For each test case, output the roll number of the student that will be Chef's partner.

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

$1 ≤ T ≤ 10^{3}$
$1 ≤ N ≤ 10^{8}$
$1 ≤ X ≤ 2N$

----- Sample Input 1 ------ 
3
2 2
3 1
3 4

----- Sample Output 1 ------ 
3
6
3
----- explanation 1 ------ 
Test case $1$: The groups will be $\{(1, 4), (2, 3)\}$. Chef's roll number is $2$, so his partner's roll number will be $3$.

Test case $2$: The groups will be $\{(1, 6), (2, 5), (3, 4)\}$. Chef's roll number is $1$, so his partner's roll number will be $6$.

Test case $3$: The groups will be $\{(1, 6), (2, 5), (3, 4)\}$. Chef's roll number is $4$, so his partner's roll number will be $3$.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
t = int(input())
for l in range(t):
	(n, x) = map(int, input().split())
	print(2 * n + 1 - x)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	print(2 * n - x + 1)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	print(2 * a + 1 - b)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(2 * a - b + 1)


T = int(input())
for _ in range(T):
	(N, X) = map(int, input().split())
	print(2 * N - X + 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n < x:
		print(2 * n - x + 1)
	else:
		print(2 * n - x + 1)


def code():
	cases = int(input())
	for _ in range(cases):
		(N, X) = map(int, input().split(' '))
		total_students = 2 * N
		print(2 * N - (X - 1))
code()


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	print(2 * x - y + 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print(2 * n - (x - 1))


T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	c = 2 * N - X + 1
	print(c)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r <= n:
		f = n - r
		print(n + f + 1)
	else:
		f = abs(n - r)
		print(n - f + 1)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if b == 1:
		print(a * 2)
	else:
		print(a * 2 - b + 1)


for _ in range(int(input())):
	(x, y) = map(int, input().split(' '))
	t1 = x * 2
	print(t1 - y + 1)


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


for _ in range(int(input())):
	(n, c) = map(int, input().split())
	l = 2 * n
	print(l - c + 1)


try:
	t = int(input())
	for r in range(t):
		(n, x) = map(int, input().split())
		print(2 * n + 1 - x)
except:
	pass


for i in range(int(input())):
	(no_of_groups, roll_number) = map(int, input().split())
	print(2 * no_of_groups - roll_number + 1)


goals = int(input())
for distractions in range(goals):
	(life, wife) = map(int, input().split())
	print(life * 2 - wife + 1)


for t in range(int(input())):
	(a, b) = map(int, input().split())
	c = 2 * a
	print(abs(b - c - 1))


for i in range(int(input())):
	(group, roll) = map(int, input().split(' '))
	print(group * 2 - roll + 1)


for t in range(int(input())):
	(num, x) = map(int, input().split())
	print(2 * num - (x - 1))


for i in range(int(input())):
	(N, X) = map(int, input().split())
	total_strength = 2 * N
	if X == 1:
		print(total_strength)
	else:
		print(total_strength - X + 1)