#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
     
}
int main()
{
    int t;cin >> t;
    while(t--)
    {
        ll n;cin >> n;
        ll sum = 0,n1 = 0;
        while(1){
        	sum = 0;n1 = n;
        	while(n1 > 0)
        	{
        		sum = sum + n1%10;
        		n1 = n1/10;
			}
			if(gcd(n,sum) > 1)
			break;
			else n++;
		}
		cout << n << endl;
	}
    
    return 0;
}
