while True:
t = int(input())
if t >=1 and t<=10**5:
break
lst = []
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<=10**9) and (y>=1 and y<=10**9):
break
if y >= x:
lst.append(y)
continue
else:
k = x
while True:
if k % y == 0:
lst.append(k)
break
k+=1
for i in lst:
print (i)