#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;
typedef pair<int, int> pi;

int grid[105][105];
int n;

void solve()
{
    cin >> n;
    if (n == 2)
    {
        cout << -1 << '\n';
        return;
    }
    for (int i = 0; i < n; i++)
        iota(grid[i], grid[i] + n, i * n + 1);
    for (int i = 0; i < n; i++)
    {
        if (i % 2)
        {
            int new_bottom = grid[0][i];
            for (int j = 0; j < n - 1; j++)
            {
                grid[j][i] = grid[j + 1][i];
            }
            grid[n - 1][i] = new_bottom;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
            cout << grid[i][j] << " ";
        cout << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}