#include <bits/stdc++.h>
using namespace std;
#define mod 1e9 + 7
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++)
#define FORL(a, b, c) for (int(a) = (b); (a) <= (c); (a)++)
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--)
#define INF 1000000000000000003
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define ff first
#define ss second
#define PB push_back
#define POB pop_back
#define MP make_pair
#define nl '\n'

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
     
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n; 
        ll ans = 1;
        while(ans<=1)
        {
            ll sumofdigits=0;
            ll counter = n;
            ll othercounter = n;
            while(counter)
            {
                sumofdigits+=(counter%10);
                counter/=10;
            }
            ans=gcd(n,sumofdigits);
            if(ans>1)
                cout<<n<<nl;
            else
                n++;     
        }
    }
    return 0;
}
