#include <bits/stdc++.h>
using namespace std;

#define PI          3.141592653589
#define ASAP       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          push_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define MP          make_pair
#define F           first
#define S           second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
int power(int x,int n)
{   int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x)%M;
            x=(x*x)%M;
            n=n/2;
        }
    return result%M;
}
int gcd(int a, int b)
{
    if(b==0) return a;
    return gcd(b, a%b);
}
bool prime(int n){
    if(n<2) return false;
    for (int x=2;x*x<=n;x++)
    {
        if(n%x==0) return false;
    }
    return true;
}

signed main(){
ASAP
    int t;
    cin>>t;
    while(t--)
    {   
        int n,sum=0;
        cin>>n;
        
        
        for(int i=n;i<n+10;i++)
        { sum=0;
          int a =n;

            while(a>0)
        {
            sum=sum+a%10;
            a=a/10;
        }

        if(gcd(n,sum)>1)
        {cout<<n<<"\n";
        break;}
        else n++;
        }
    }
}