#MOHIB. Mohib and series

Mohib and series

Mohib (CoolWink), as we all known, is very brilliant in mathematics. His friend Bar has given him another problem to solve.

Bar gives him a sequence of distinct positive integers, whose average is (A+1).

If Bar append an integer x to the sequence, then the average of integers in the sequence will be A.

He asked the Mohib to tell him the largest possible integer in the sequence.

Input

First line contains T, the number of testcases (T <= 5000). 

Next T lines contain an integer x (1 <= x <= 49999) and A (x+1 <= A <= 50000).

Output

Print the largest possible integer in the sequence.

Example

Input:
1
1 2

Output: 3

</p>