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):
if (y>=1 and y<=10**9):
break
if y >= x:
lst.append(y)
continue
else:
for k in range (x, 9999):
if k % y == 0:
lst.append(k)
break
for i in lst:
print (i)