#include <bits/stdc++.h>
using namespace std;
#define IAMSPEED ios_base::sync_with_stdio(0); cin.tie(0);
const int mod = 998244353;
const int oo = 1000000010;
const int N = 200010;
void solve(){
string str;
int y, need = 0;
cin >> str >> y;
for(int i = 0; i < (int)str.size(); ++i){
need = ((long long)need * 10 + str[i] - '0') % y;
}
if(need == 0){
cout << str << '\n';
return;
}
str = '0' + str;
need = y - need;
bool carry = false;
for(int i = (int)str.size() - 1; i >= 0; --i){
int x = str[i] - '0' + carry + need % 10;
carry = (x >= 10);
str[i] = x % 10 + '0';
need /= 10;
}
for(int i = (str[0] == '0'); i < (int)str.size(); ++i){
cout << str[i];
}
cout << '\n';
}
int main(){
IAMSPEED
int t = 1;
cin >> t;
while(t--){
solve();
}
return 0;
}
Copy