#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int t, n, a, b, ans, l;
int main()
{
scanf("%d", &t);//这句话是为了确定一个最大的范围,比如说10000
while (t--)
{
scanf("%d", &n);
ans = 0;
for (int i = n - 50; i < n; ++i)
{
a = b = i;
while (b)
{
a += b % 10;
b /= 10;
}
if (a == n)
{
ans = i;
break;
}
}
printf("%d\n", ans);
}
return 0;
}