T = int(input())
for i in range(T):
a , b = map(int, input().split())
x = 1
while (b*x)%a != 0:
x += 1
print(b*x)



어쩐지 실버문제가 5분만에 풀리더니만.. 운수좋은날이였네