#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;

int n,k;
int cnt[3010][3010];
int cur;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("DIVGROUP.INP","r",stdin);
    //freopen("DIVGROUP.OUT","w",stdout);
    cin >> n >> k;
    for(int i = 0; i < k;i++){
        cnt[i+1][i+1] = n*n - i;
    }
    cur = n*n - k;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(i == j && i <= k) continue;
            else cnt[i][j] = cur--;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cout << cnt[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}
