#include<iostream>
using namespace std;
int main() {
int n;
long long int x, y;
cin >> n;
for (int i = 1;i <= n;i++) {
cin >> x >> y;
long long int k = x;
int l = k % y;
k = k - l;
k = k + y;
while (1) {
if (k % y == 0)
{
cout << k << endl;
break;
}
k=k+y;
}
}
return 0;
}