#include #include using namespace std; using int64 = long long; int main() { int T; cin >> T; while(T--) { int N; cin >> N; for(int i = 1;; i++) { if(stoll(to_string(N) + to_string(i)) % (N + i) == 0) { cout << i << "\n"; break; } } } }