#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int add(int a, int b) {
  a += b;
  if (a >= MOD) {
    return a - MOD;
  }
  if (a < 0) {
    return a + MOD;
  }
  return a;
}
int mul(int a, int b) { return a * (long long)b % MOD; }
int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) {
      r = mul(r, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return r;
}
int dv(int a, int b) { return mul(a, pw(b, MOD - 2)); }
const int N = (int)2e3 + 7;
int n;
int k;
int a[N];
int survive[N][N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    int start = max(1, i - k + 1);
    for (int j = 0; j < start; j++) {
      survive[i][j] = 1;
    }
    for (int j = start; j <= n; j++) {
      int rem = min(n - j + 1, k);
      survive[i][j] = mul(survive[i][j - 1], dv(rem - 1, rem));
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      cout << survive[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
