#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using ull = unsigned long long; using vi = vector; using vvi = vector; using vc = vector; using vvc = vector; using vb = vector; using vvb = vector; using vs = vector; using pii = pair; using vpii = vector; using mint = modint998244353; // using mint = modint1000000007; #define endl '\n' #define rep(i, a) for (ll i = 0; i < a; i++) #define f(i, a, b) for (ll i = a; i < b; i++) #define rf(i, a, b) for (ll i = a; i > b; i--) const ll INF = LLONG_MAX / 4; void io_setup() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); } int main(void) { io_setup(); ll t; cin >> t; rep(T,t) { int n; cin >> n; f(i, 1,n) { ll k = i; ll s = n; while (k > 0) { k /= 10; s *= 10; } if ((s + i) % (n + i) == 0) { cout << i << endl; break; } } } }