#include #include using namespace std; using namespace atcoder; #define ll long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define repl(i,a,b) for(ll i=(a);i<(b);i++) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() template bool chmin(T &a,T b){if(a>b){a=b;return true;} return false;} template bool chmax(T &a,T b){if(a> n >> k; if(k == 0){ cout << "-1\n"; return; } vector a(n,vector(n)); int now=n*n-k+1; int x=0,y=0; while(now<=n*n){ a[x][y]=now++; if(x == n-1){ x=0; y++; } else x++; } now=1; while(y> T; rep(_,0,T){ solve(); } }