#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int t,x,y,k;
int g(int x, int y){
int j = y;
while(x > y){
y += j;
}
return y;
}
int main()
{
cin>>t;
for(int i=0;i<t;i++){
cin>>x>>y;
cout<<g(x, y)<<endl;
}
return 0;
}