MOHIB  Mohib and series
Mohib (), 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
hide comments
seastian:
20200222 12:47:30
for largest don't check for x 

prachij:
20191221 10:17:22
AC in one go!!! 

robosapien:
20191209 19:18:49
AC in one go :P 

arsundram:
20191004 17:55:21
AC in one go!! Last edit: 20191004 18:20:22 

kushrike:
20190508 12:47:13
logical_reasoning 

silentknight16:
20190222 13:49:28
More of math.... Last edit: 20190222 13:50:05 

abhinav_99:
20190108 13:10:42
remember that sequence has distinct elements 

D Pratap :
20180609 16:13:35
got TLE for O(1) solution in Java .


ankit1cool:
20170606 19:58:11
just take take that 0 is neither positive nor negative 

sspratap16:
20170121 07:07:47
distinct number sequence starts from 1 not zero cost me 2 wa..but ques is simple... 
Added by:  MoHib85 
Date:  20150517 
Time limit:  0.100s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ADA95 ASM32GCC ASM32 ASM64 GAWK BASH JSMONKEY 