#include "bits/stdc++.h"
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
using ll = long long int;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	int t; cin >> t;
	while (t--) {
		int n; cin >> n;
		if (n == 1) cout << 1 << '\n' << 1 << '\n';
		else if (n%2) cout << -1 << '\n';
		else {
			vector<int> ans(n+1);
			for (int i = n; i >= 1; --i) cout << i << ' ';
			cout << '\n';
			int full = 1;
			while (full <= n) full *= 2;
			for (int i = n; i >= 1; --i) {
				if (ans[i]) {
					cout << ans[i] << ' ';
					continue;
				}
				while (2*i < full) full /= 2;
				cout << full-1-i << ' ';
				ans[full-1-i] = i;
			}
			cout << '\n';
		}
	}	
}