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

  long long gcd(long long a,long long b)
  {
    while(b!=0)
    {
        int temp=b;
        b=a%b;
        a=temp;
    }
    return a;
  }

long long val (long long n)
{
    long long sum=0,t=n;
    while(t!=0)
    {
        sum=sum+(t%10);
        t=t/10;

    }
    return sum;
}





int main()
    {

           int t;
           cin>>t;
           while(t--)
           {
               long long n;
               cin>>n;

               while(1)
               {
                   if( gcd (n,val(n))>1 )
                   {
                       cout<<n<<endl;
                       break;
                   }
                   else
                    n++;
               }

           }



            return 0;
    }
