#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, k2, a[100000] = {0}, k1, b[100000] = {0}, i, j;
  cin >> n >> k;
  for (i = 1; i < n; i++) a[i] = 1;
  a[n] = 0;
  for (i = 1; i < n; i++) {
    a[i] = 2;
    cout << i + 1 << " ";
  }
  cout << n << endl;
  b[n] = n;
  k2 = n;
  for (i = 1; i < k; i++) {
    for (j = 1; j <= n; j++) {
      if (a[j] + a[j] <= n - j) {
        b[j] = j + 1;
        a[j] = a[j] + a[j + 1];
      } else {
        for (k1 = j; k1 <= n; k1++) {
          b[k1] = n - ((n - k1) - a[k1]);
          if (b[k1] > n) b[k1] = n;
          a[k1] = n - k1;
        }
        break;
      }
      if (b[j] > n) b[j] = n;
    }
    for (k1 = 1; k1 <= n; k1++) cout << b[k1] << " ";
    cout << endl;
  }
  return 0;
}
