#include <iostream>
using namespace std;

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

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

        if (n > 45)
        {
            cout << -1 << endl;
        }
        else
        {
            int k = 9;
            int res = 0, p = 1;

            while (n > k)
            {
                n -= k;
                res += k*p;
                p *= 10;
                k--; 
            }

            res += n*p;

            cout << res << endl;
        }
        
    }

    return 0;
}