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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int x;
    cin >> x;
    vector<int> res;
    for (int i = 9; i >= 1 && x > 0; i--) {
      int cur = min(i, x);
      x -= cur;
      res.push_back(cur);
    }
    if (x > 0) {
      cout << "-1\n";
    } else {
      sort(res.begin(), res.end());
      for (int p : res)
        cout << p;
      cout << '\n';
    }
  } 
  return 0;
}