
#include <bits/stdc++.h>
using namespace std;
void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main(){
    fastio();
    int tc;
    cin>>tc;
    while(tc--){
        int n;
        cin>>n;
        int ans[n][n];
        vector<int>a;
        if (n==2){
        	cout<<-1<<endl;
        }
        else{
        for(int i=2;i<=n*n;i+=2){
        	a.push_back(i);
        	
        }
        for(int j=1;j<=n*n;j+=2){
        	a.push_back(j);
        }
        
        int c=0;
        for (int i=0;i<n;i++){
        	for(int j=0;j<n;j++){
        		ans[j][i]=a[c];
        		c+=1;
        	}
        }
        for(int i=0;i<n;i++){
        	for(int j=0;j<n;j++){
        		cout<<ans[j][i]<<" ";
        	}
        	cout<<endl;
        }
    }
    }
    return 0;
}