#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; using namespace chrono; int main(){ int t; cin>>t; while(t--){ ll n; cin>>n; int k=0; ll s=n; while(s>0){ k++; s/=10; } ll m=1; rep(i,k) m*=10; m--; m-=n; cout<