#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t; cin >> t;
	while(t--)
	{
		int x; cin >> x;
		set <int> s;
		for(int i = 9; i > 0 && x > 0; i--)
			if(i <= x) x -= i, s.insert(i);
		if(x > 0) cout << -1;
		else
			for(auto i : s) cout << i;
		cout << "\n";
	}
	return 0;
}
