#include<iostream>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string.h>
using namespace std;
typedef long long ll;
const int maxn=2e4+10;
const int inf=99999999;
int a[maxn];
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
if(n<=9)
{
cout<<n<<endl;continue;
}
if(n>45)
{
cout<<"-1"<<endl;continue;
}
int sum=0;
int num[111];
int tot=0,ok=0;
int all=n;
for(int i=9;i>=1;i--)
{
if(sum+i>n)
continue;
sum+=i;
num[tot++]=i;
if(sum==n)
{
ok=1;break;
}
}
if(ok)
{
for(int i=tot-1;i>=0;i--)
cout<<num[i];
cout<<endl;
}
else
cout<<"-1"<<endl;
}
}