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

long long n;
void Answer(long long n) {
	
	long long n1 = n;
	long long sum=0;

	while(n1) {
		long long rem = n1 % 10;
		sum += rem;
		n1/=10;
	}
	long long n2 = n;
	while(n2 % sum != 0) {
		long long rem = n2 % sum;
		n2 = sum;
		sum = rem;
	}

	long long gcd = sum;
	if(gcd <= 1) {
		Answer(n+1);
	} else if(gcd > 1) {
		cout << n << "\n";
		return;
	}
}

void solve() {
	cin >> n;
	Answer(n);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long t;
	cin >> t;
	while(t--) {
	solve();
	}
	return 0;
}
