while True:
t = int(input())
if t >=1 and t<=100000:
break
for i in range(t):
while True:
x = int (input())
y = int (input())
if (x>=1 and x<=1000000000):
if (y>=1 and y<=1000000000):
break
if y >= x:
print (y)
continue
else:
for k in range (x, 9999):
if k % y == 0:
print (k)
break