#include <bits/stdc++.h>   using namespace std;      #define pb push_back   #define f first   #define s second   #define ll long long         ll MOD = 1000000007;      int main(){    ll t;    cin>>t;    while(t--){     ll n;     cin>>n;     int c =1;     if(n==1)cout<<1<<endl;     if(n==2)cout<<-1<<endl;     if(n>=3){      for(int i=0;i<n;i++){       for(int j=0;j<n;j++){        cout<<c<<   ;        c+=2;        if(c>n*n)c=2;       }       cout<<endl;      }     }    }   }