#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;cin >> N; int K;cin >> K; if(K == 0){ cout << -1 << nl; return 0; } vector>ans(N,vector(N,-1)); vectorwritten(N*N+1); int diff = K-1; int biggest = N*N; pairwhere = {diff/N,diff%N}; int semi_biggest = N; diff %= N; pairplace = {0,diff}; ans[where.first][where.second] = biggest; written[biggest] = true; if(ans[place.first][place.second] != biggest){ ans[place.first][place.second] = semi_biggest; written[semi_biggest] = true; } int current = 1; rep(i,N*N){ int h = i/N; int w = i%N; while(written[current])current++; if(ans[h][w] == -1){ ans[h][w] = current; written[current] = true; } } rep(i,N){ rep(j,N){ cout << ans[i][j] << " "; } cout << nl; } }