// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#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 k = x + 1;
for (int i = 0;i < 100;i++) {
if (k % y == 0) {
cout << k << endl;
break;
}
k++;
}
}
}