/*(^-^)*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll x,ll y)
{
	return x % y ? gcd(y, x % y) : y;
}
void solve()
{
	ll n,x=0;
	cin >> n;
	ll mid = n;
	int ji = 0;
	do
	{
		if (ji) {
			n++;
			x = 0;
			mid = n ;
		}
		while (mid)
		{
			x += mid % 10;
			mid /= 10;
		}
		ji++;
	} 	while (gcd(n, x) == 1);
	cout <<n<< endl;;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int t;
	cin >> t;
	while (t--)
	solve();
	return 0;
}