#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
string solve(string s1, string s2){
int len = max(s1.size(), s2.size());
while(s1.size() != len) s1 = "0" + s1;
while(s2.size() != len) s2 = "0" + s2;
if(s2 > s1) swap(s1,s2);
int nho = 0;
string tmp = "";
for(int i = s1.size()-1; i >= 0; i--){
int x = (s1[i] - '0') - (s2[i] - '0') - nho;
if(x < 0){
x += 10;
nho = 1;
}
else{
nho = 0;
}
tmp = to_string(x) + tmp;
}
return tmp;
}
int main(){
int t;
cin >> t;
while(t--){
string s1, s2;
cin >> s1 >> s2;
cout << solve(s1,s2) << endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZW5kbCAiXG4iCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnR5cGVkZWYgbG9uZyBsb25nIGxsOwpjb25zdCBpbnQgbW9kID0gMWU5ICsgNzsKCnN0cmluZyBzb2x2ZShzdHJpbmcgczEsIHN0cmluZyBzMil7CglpbnQgbGVuID0gbWF4KHMxLnNpemUoKSwgczIuc2l6ZSgpKTsKCXdoaWxlKHMxLnNpemUoKSAhPSBsZW4pIHMxID0gIjAiICsgczE7Cgl3aGlsZShzMi5zaXplKCkgIT0gbGVuKSBzMiA9ICIwIiArIHMyOwoJaWYoczIgPiBzMSkgc3dhcChzMSxzMik7CglpbnQgbmhvID0gMDsKCXN0cmluZyB0bXAgPSAiIjsKCWZvcihpbnQgaSA9IHMxLnNpemUoKS0xOyBpID49IDA7IGktLSl7CgkJaW50IHggPSAoczFbaV0gLSAnMCcpIC0gKHMyW2ldIC0gJzAnKSAtIG5obzsKCQlpZih4IDwgMCl7CgkJCXggKz0gMTA7CgkJCW5obyA9IDE7CgkJfQoJCWVsc2V7CgkJCW5obyA9IDA7CgkJfQoJCXRtcCA9IHRvX3N0cmluZyh4KSArIHRtcDsKCX0KCXJldHVybiB0bXA7Cn0KCmludCBtYWluKCl7CglpbnQgdDsKCWNpbiA+PiB0OwoJd2hpbGUodC0tKXsKCQlzdHJpbmcgczEsIHMyOwoJCWNpbiA+PiBzMSA+PiBzMjsKCQljb3V0IDw8IHNvbHZlKHMxLHMyKSA8PCBlbmRsOwoJfQp9