while True:
t = int(input())
if t >=1 and t<=100000:
break
for i in range(t):
while True:
l = (input())
l = l.split(" ")
x = int(l[0])
y = int(l[1])
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