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

int sum(long long int n)
{
	int s =0 ;
	while(n)
		{
			s += (n%10);
			n /= 10;
		}
	return s;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	long long int n;
	cin>>t;
	while(t--)
	{
		cin>>n;
		
		do
			{
				if(gcd(n,sum(n)) >1)
					break;
				n++;	
			}
		while(1);
		cout<<n<<"\n";
	}
	return 0;
}
