#include <iostream>
using namespace std;
int main()
{
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int x, y;
cin >> x >> y;
int j = x + 1;
if (y > x) {
cout << y << endl;
continue;
}
while (j % y != 0) {
j++;
}
cout << j << endl;
}
}