#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
    int t;
    cin>>t;

    while(t--) {
        int x;
        cin>>x;

        int sum=0;
        int last=9;

        vector<int> a;


        while(sum<x && last>0) {
            a.push_back(min(x-sum,last));
            sum+=last;
            last--;

        }

        if(sum<x)
        cout<<-1<<endl;

        else {
            reverse(a.begin(),a.end());

            for(int i=0;i<a.size();i++)
            cout<<a[i];
            cout<<endl;
        }
    }

    return 0;

}