#include <iostream>
using namespace std;
int main() {
int x, y, counter=0 , n,k;
int a[100000], b[100000];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x >> y;
for (int i = 0; i < 10000; i++) {
a[i] = i * y;
if ((a[i] > x) && (a[i] % y == 0)) {
k = a[i];
b[counter] = k;
counter++;
break;
}
}
}
for (int j = 0; j < n; j++) {
cout << b[j] << endl;
}
return 0;
}