#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
	int t;
	cin >> t;

	while (t--) {
		int n;
		cin >> n;
		if (n == 1) {
			cout << 1 << endl;
			continue;
		}
		else if (n == 2) {
			cout << -1<<endl;
			continue;
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j % 2 == 1) {
					if (i == n - 1) {
						cout<< j + 1;
					}
					else {
						cout<< n * (i+1) + j + 1;
					}
					
				}
				else {
					cout<< i * (n) + j + 1;
				}
				cout << " ";
			}
			cout << endl;
		}
	}

	return 0;
}