#include <iostream>
using namespace std;
int cnt[111];
bool check(long long n, int k) {
for(int i = 0; i < k; ++i)
cnt[i] = 0;
long long u = n;
while (u) {
cnt[u % 10]++;
u /= 10;
}
for(int pos = k-1; pos >= 0; --pos)
if (cnt[pos] != n % 10) return false;
else n /= 10;
return true;
}
int main() {
int ntest; cin >> ntest;
while (ntest--) {
int k; cin >> k;
long long lb = 1; for(int turn = 0; turn < k-1; ++turn) lb *= 10;
long long ub = 1; for(int turn = 0; turn < k; ++turn) ub *= 10; --ub;
bool ok = false;
for(long long x = lb; x <= ub; ++x) {
if (check(x, k)) {
ok = true;
cout << x << ' ';
}
}
if (!ok) cout << -1 << endl;
else cout << endl;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGNudFsxMTFdOwpib29sIGNoZWNrKGxvbmcgbG9uZyBuLCBpbnQgaykgewogICAgZm9yKGludCBpID0gMDsgaSA8IGs7ICsraSkKICAgICAgICBjbnRbaV0gPSAwOwoKICAgIGxvbmcgbG9uZyB1ID0gbjsKICAgIHdoaWxlICh1KSB7CiAgICAgICAgY250W3UgJSAxMF0rKzsKICAgICAgICB1IC89IDEwOwogICAgfQoKICAgIGZvcihpbnQgcG9zID0gay0xOyBwb3MgPj0gMDsgLS1wb3MpCiAgICAgICAgaWYgKGNudFtwb3NdICE9IG4gJSAxMCkgcmV0dXJuIGZhbHNlOwogICAgICAgIGVsc2UgbiAvPSAxMDsKICAgIHJldHVybiB0cnVlOwp9CgppbnQgbWFpbigpIHsKICAgIGludCBudGVzdDsgY2luID4+IG50ZXN0OwogICAgd2hpbGUgKG50ZXN0LS0pIHsKICAgICAgICBpbnQgazsgY2luID4+IGs7CiAgICAgICAgbG9uZyBsb25nIGxiID0gMTsgZm9yKGludCB0dXJuID0gMDsgdHVybiA8IGstMTsgKyt0dXJuKSBsYiAqPSAxMDsKICAgICAgICBsb25nIGxvbmcgdWIgPSAxOyBmb3IoaW50IHR1cm4gPSAwOyB0dXJuIDwgazsgKyt0dXJuKSB1YiAqPSAxMDsgLS11YjsKCiAgICAgICAgYm9vbCBvayA9IGZhbHNlOwogICAgICAgIGZvcihsb25nIGxvbmcgeCA9IGxiOyB4IDw9IHViOyArK3gpIHsKICAgICAgICAgICAgaWYgKGNoZWNrKHgsIGspKSB7CiAgICAgICAgICAgICAgICBvayA9IHRydWU7CiAgICAgICAgICAgICAgICBjb3V0IDw8IHggPDwgJyAnOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICghb2spIGNvdXQgPDwgLTEgPDwgZW5kbDsKICAgICAgICBlbHNlIGNvdXQgPDwgZW5kbDsKICAgIH0KfQo=