#include <iostream>#include <fstream>usingnamespacestd;
voidsolve(intn);
intmain()
{
#ifndef ONLINE_JUDGEifstreamfin("d:\\OJ\\uva_in.txt");
streambuf*old=cin.rdbuf(fin.rdbuf());
#endif intn;
cin>>n;
while (n--) {
intnum;
cin>>num;
solve(num);
}
#ifndef ONLINE_JUDGEcin.rdbuf(old);
#endif return0;
}
voidsolve(intn)
{
intdigits=0;
intnum=n;
while (num) {
digits++;
num/=10;
}
boolfound=false;
for (inti=n-digits*9; i<n; i++) {
intsum=i;
num=i;
while (num) {
sum+=num%10;
num/=10;
}
if (sum==n) {
found=true;
cout<<i<<endl;
break;
}
}
if (!found) cout<<0<<endl;
}