import sys
from math import gcd
def f(n):
s=str(n)
x=0
for i in range(len(s)):
x=x+int(s[i])
return x
for _ in range(int(sys.stdin.readline())):
n=int(sys.stdin.readline())
s1=f(n)
s2=f(n+1)
if gcd(s1,n)>1:
print(n)
elif gcd(s2,n+1)>1:
print(n+1)
else:
print(n+2)
/**
* author: Mohammed-issa
* created: 00.00.00
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
long long n;
cin >> n;
while (true) {
long long n2 = n;
int sum = 0;
while (n2 > 0) {
sum += n2 % 10;
n2 /= 10;
}
if (gcd(n, sum) > 1) {
cout << n << endl;
break;
}
n++;
}
}
}
1729D - Friends and the Restaurant | 1606C - Banknotes |
580C - Kefa and Park | 342A - Xenia and Divisors |
1033A - King Escape | 39D - Cubical Planet |
1453A - Cancel the Trains | 645A - Amity Assessment |
1144A - Diverse Strings | 1553B - Reverse String |
1073A - Diverse Substring | 630N - Forecast |
312B - Archer | 34D - Road Map |
630I - Parking Lot | 160B - Unlucky Ticket |
371B - Fox Dividing Cheese | 584B - Kolya and Tanya |
137B - Permutation | 550C - Divisibility by Eight |
5A - Chat Servers Outgoing Traffic | 615A - Bulbs |
5B - Center Alignment | 549A - Face Detection |
535B - Tavas and SaDDas | 722C - Destroying Array |
366A - Dima and Guards | 716B - Complete the Word |
1461C - Random Events | 1627A - Not Shading |