func_code_string: #include<bits/stdc++.h>   using namespace std;   #define ll long long int   #define v vector<ll>   #define pb push_back   #define fr(i,a,n) for(ll i=a;i<n;i++)   #define Fast ios::sync_with_stdio(false);cin.tie(NULL);   #define in(a) ll a;cin>>a   #define ip(a) string a;cin>>a   #define R(a,n) for(int i=0;i<n;i++)cin>>a[i];   #define all(a) sort(a.begin(),a.end())   #define e endl   #define MOD (int)1e9 + 7   inline ll powe(ll a,ll b , ll p = MOD){ ll ans=1;for(;b;b>>=1){if(b&1) ans=ans*a%p;a=a*a%p;} return ans;}   void solve(){      in(n);      if(n==2)cout<< -1 <<e;      else{           ll pp=1;           ll size=n*n;           fr(i,0,n){             fr(j,0,n){               cout<<pp<<   ;               if(pp+2>size){                pp=2;         }         else{          pp+=2;         }       }       cout<<e;        }      }      }   int main()   {       Fast       ll t;cin>>t;       while(t--){           solve();       }   }