#include <bits/stdc++.h>
#define imad int main
#define ull unsigned long long
#define ll long long
#define el endl
#define pb push_back
#define ppb pop_back
#define all(v) v.begin(), v.end()
#define nl '\n'
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
using namespace std;

vector<ll> getDivisors(ll n, ll &sum)
{
    vector<ll> div;
    sum = 0;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            div.pb(i);
            sum += i;
            if (n / i != i)
            {
                div.pb(n / i);
                sum += n / i;
            }
        }
    }
    sort(all(div));
    return div;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i += 6)
    {
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}

imad()
{
    IOS;

    ll Q = 1;
    cin >> Q;
    while (Q--)
    {

        int n;
        cin >> n;

        if (n <= 3)
        {
            cout << "-1" << nl;
            continue;
        }
        int idx = 1;
        int x = n;

        if (n % 2 != 0)
        {
            n--;
        }
        while (n > 0)
        {
            if (!isPrime(idx * n))
            {
                cout << n << " ";
                n--, idx++;
            }
            else
            {
                cout << n - 1 << ' ' << n << ' ';
                n -= 2, idx += 2;
            }
        }
        if (x % 2 != 0)
        {
            cout << x;
        }
        cout << nl;
    }
    return 0;
}