#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t--){
string s;
cin >> s;
int len = s.length();
int m=0;
for(int i=0; i<len; i++){
int t = s[i] - '0';
m = m*10 + t;
}
int n = pow(10, len);
cout << m-n << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCB0OwoJY2luID4+IHQ7Cgl3aGlsZSh0LS0pewoJCXN0cmluZyBzOwoJCWNpbiA+PiBzOwoJCWludCBsZW4gPSBzLmxlbmd0aCgpOwoJCWludCBtPTA7CgkJZm9yKGludCBpPTA7IGk8bGVuOyBpKyspewoJCQlpbnQgdCA9IHNbaV0gLSAnMCc7CgkJCW0gPSBtKjEwICsgdDsKCQl9CgkJaW50IG4gPSBwb3coMTAsIGxlbik7CgkJY291dCA8PCBtLW4gPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9