Meliodas and Ban are fighting over chocolates. Meliodas has $X$ chocolates, while Ban has $Y$. Whoever has lesser number of chocolates eats as many chocolates as he has from the other's collection. This eatfest war continues till either they have the same number of chocolates, or atleast one of them is left with no chocolates.

Can you help Elizabeth predict the total no of chocolates they'll be left with at the end of their war?

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase contains of a single line of input, which contains two integers $X, Y$, the no of chocolates Meliodas and Ban have, respectively. 

-----Output:-----
For each testcase, output in a single line the no of chocolates that remain after Ban and Meliodas stop fighting.

-----Constraints-----
- $1 \leq T \leq 100000$
- $0 \leq X,Y \leq 10^9$

-----Sample Input:-----
3

5 3

10 10

4 8  

-----Sample Output:-----
2

20

8  

-----EXPLANATION:-----
Denoting Meliodas as $M$, Ban as $B$.
Testcase 1:
$M$=5, $B$=3

Ban eates 3 chocolates of Meliodas.
$M$=2, $B$=3

Meliodas eats 2 chocolates of Ban.
$M$=2, $B$=1

Ban eates 1 chocolate of Meliodas.
$M$=1, $B$=1

Since they have the same no of candies, they stop quarreling.

Total candies left: 2  
Testcase 2:
$M$=10, $B$=10

Since both of them had the same candies to begin with, there was no point in fighting.

Total candies left: 20  
Testcase 3:
$M$=4, $B$=8

Meliodas eats 4 chocolates of Ban.
$M$=4, $B$=4

Since they have the same no of candies, they stop quarreling.

Total candies left: 8

Starter code:

Solutions:
from math import *
t=int(input())
for i in range(t):
 m,b=input().split()
 m=int(m)
 b=int(b)
 print(2*gcd(m,b))

from math import*
n=int(input())
for i in range(n):
 b,m=input().split()
 b=int(b)
 m=int(m)
 print(2*gcd(b,m))

from math import*
for i in range(int(input())):
 m,b=input().split()
 m=int(m)
 b=int(b)
 print(2*gcd(m,b))

from math import *
t=int(input())
for i in range(t):
 m,b=input().split()
 m=int(m)
 b=int(b)
 print(2*gcd(m,b))

def gcd(a, b):
 if b == 0:
  return a
 return gcd(b, a%b)

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

 print(2 * gcd(a, b))

from math import *
t=int(input())
for i in range(t):
 a,b=map(int,input().split())
 a=int(a)
 b=int(b)
 print(2*gcd(a,b))

# cook your dish here
def gcd(a, b):
 if b==0:
  return a 
 return gcd(b, a%b)

for _ in range(int(input())):
 M, B = map(int, input().split())
 g = gcd(M, B)
 print(2 * g)

# cook your dish here
def fun(M,B):
 if M==B:
  return M*2
 elif M==0:
  return B*2
 elif B==0:
  return M*2
 else:
  if M>B:
   return fun(M%B,B)
  else:
   return fun(M,B%M)
t = int(input())
for i in range(t):
 M,B=list(map(int,input().split()))
  
 print(fun(M,B))


# cook your dish here
def gcd(a, b):
 if b==0:
  return a 
 return gcd(b, a%b)

for _ in range(int(input())):
 M, B = map(int, input().split())
 g = gcd(M, B)
 print(2 * g)

from math import *
t=int(input())
for i in range(t):
 m,b=input().split()
 m=int(m)
 b=int(b)
 print(2*gcd(m,b))

# cook your dish here
for _ in range(int(input())):
 [m,b]=[int(i) for i in input().split()]
 def E(m,b):
  if m<b:
   return E(b,m)
  if b==0:
   return m
  return E(b,m%b)
 print(2*E(m,b))

# cook your dish here
def chocoValue(a,b):
 if a<b:
  a,b=b,a
 if b==0: 
  return a
 return chocoValue(b,a%b)


for x in range(int(input())):
 m,b=map(int,input().split())
 if m or b:
  sumValue= chocoValue(m,b)
  print(2*sumValue)
 else:
  print(0)

def gcd(a,b):
 if a<b:
  a,b=b,a
 if b==0:
  return a
 return gcd(b,a%b)
 
for _ in range(int(input())):
 a,b=map(int,input().split())
 if a or b:
  c=gcd(a,b)
  print(2*c)
 else:
  print(0)

# cook your dish here
import math
for _ in range(int(input())):
 m, b = map(int,input().split())
 print(2*math.gcd(m, b))

# cook your dish here
import math
for i in range(int(input())):
 n,m=map(int,input().split())
 if n==m or n==0 or m==0:
  print(n+m)
 else:
  a=math.gcd(n,m)
  print(2*a)

# cook your dish here
import math
for _ in range(int(input())):
 n,m=map(int,input().split())
 if n==m or n==0 or m==0:
  print(n+m)
 else:
  x=math.gcd(n,m)
  print(2*x)

t=int(input())
for _ in range(t):
 a,b=list(map(int,input().split()))
 while a!=0 and b!=0 and a!=b:
  if(a>b):
   a=a%b
  else:
   b=b%a
 if(a==0 or b==0):
  print((a+b)*2)
 elif(a==b):
  print(a+b)


# cook your dish here
def gcd(m,b):
 if m==0:
  return b
 return gcd(b%m,m)

test = int(input())

while test!=0:
 m,b = list(map(int,input().split()))
 result = gcd(m,b)
 print(result*2)
 test-=1



def gcd(m,b):
 if m==0:
  return b
 return gcd(b%m,m)

test = int(input())

while test!=0:
 m,b = list(map(int,input().split()))
 result = gcd(m,b)
 print(result*2)
 test-=1




from math import gcd
for i in range(int(input())):
 a,s=list(map(int,input().split()))
 print(gcd(a,s)*2)

t = int(input())

def gcd(a, b):
 if(b==0):
  return a
 else:
  return gcd(b, a%b)

for _ in range(t):
 x, y = [int(a) for a in input().split()]
 
 print(gcd(x, y)*2)

from math import gcd
for _ in range(int(input())) :
 a, b = map(int, input().split())
 print(2 * gcd(a, b))

# cook your dish here
from math import gcd
for _ in range(int(input())):
 x,y= map(int,input().split())
 if x==y:
  print(x+y)
 else:
  print(2*gcd(x,y))

# cook your dish here
for _ in range(int(input())):
 x, y = list(map(int, input().split()))
 
 while(y):
  x, y = y, x % y
 
 print(2*x)