#include #include using namespace std; using namespace atcoder; using ll = long long; #define all(x) x.begin(), x.end() #define rep(i, limit) for (int i = 0; i < (int)limit; i++) constexpr char nl = '\n'; constexpr int INF = 1'000'000'000; constexpr ll LINF = 2'000'000'000'000'000'000LL; 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 < b){a = b; return true;} return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,K;cin >> N >> K; if(K == 0){ cout << -1 << nl; return 0; } K--; int top_left = N*N - K; vector>ans(N,vector(N)); ans[0][0] = top_left; vectorused(N*N+1); used[top_left] = true; int current = 1; for(int i = 0; i < N*N; i++){ int h = i/N; int w = i%N; while(used[current])current++; if(ans[h][w] == 0){ ans[h][w] = current; used[current] = true; } } rep(i,N){ rep(j,N){ cout << ans[i][j] << " "; } cout << nl; } }