#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
const int INF = ~(1 << 31);
const double EPS = 1;
const double PI = 3.141592653589793;
int main() {
  int n, k;
  cin >> n >> k;
  if (n == 1) {
    for (int i = 0; i < k; i++) {
      cout << "1\n";
    }
    return 0;
  }
  vector<int> a(n, 1);
  a[n - 1] = 0;
  vector<vector<int> > c(k, vector<int>(n, n));
  int p = n - 3;
  for (int i = 0; i < k; i++) {
    int l = p - a[p + 1];
    int j = 1;
    for (; p >= 0 && p > l; p--) {
      c[i][p] = n - j;
      a[p] += a[n - j - 1];
      j++;
    }
    int add = a[0];
    for (j = 0; j <= p; j++) {
      c[i][j] = 1;
      a[j] += add;
    }
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j++) {
      cout << c[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}
