我怀疑我偷渡成功
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);cout.tie(0);
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
int t;
scanf("%d",&t);
while(t--){
int n,k,p=0;
scanf("%d%d",&n,&k);
if(n==1||k==1||2*n*(n+1)%k){puts("-1");continue;}
for(int i=1;i<=2*n+2;i++){
for(int j=1;j<=n;j++){
printf("%d ",p+1);
p=(p+1)%k;
}
if(n%k==0)p=(p+1)%k;
puts("");
}
}
return 0;
}