#include <iostream>
using namespace std;

int main() {
	   int t;
    cin>>t;
    int g=19;
    int a=189;
    int b=1789,c=16789,d=156789,e=1456789,f=13456789;
    while(t--)
    {
        int n;
        cin>>n;
        if(n>45)
        cout<<-1<<endl;
        else if(n<10)
        cout<<n<<endl;
        else if(n>=10&&n<=17)
        cout<<(n-10)*10+g<<endl;
        else if(n>17&&n<25)
        cout<<(n-18)*100+a<<endl;
        else if(n>=25&&n<31)
        cout<<(n-25)*1000+b<<endl;
        else if(n>=31&&n<=35)
        cout<<(n-31)*10000+c<<endl;
        else if(n>=36&&n<=39)
        cout<<(n-36)*100000+d<<endl;
        else if(n>=40&&n<=42)
        cout<<(n-40)*1000000+e<<endl;
        else if(n>=43&&n<=44)
        cout<<(n-43)*10000000+f<<endl;
        else
        cout<<123456789<<endl;
        
    }
}