Problem: Note that the only differences between easy and hard versions are the constraints on n and the time limit. You can make hacks only if all versions are solved.

Slime is interested in sequences. He defined good positive integer sequences p of length n as follows:

  * For each k>1 that presents in p, there should be at least one pair of indices i,j, such that 1 ≤ i < j ≤ n, p_i = k - 1 and p_j = k.



For the given integer n, the set of all good sequences of length n is s_n. For the fixed integer k and the sequence p, let f_p(k) be the number of times that k appears in p. For each k from 1 to n, Slime wants to know the following value:

$$$\left(∑_{p∈ s_n} f_p(k)\right)\ mod\ 998 244 353$$$

Input

The first line contains one integer n\ (1≤ n≤ 5000).

Output

Print n integers, the i-th of them should be equal to \left(∑_{p∈ s_n} f_p(i)\right)\ mod\ 998 244 353.

Examples

Input


2


Output


3 1 


Input


3


Output


10 7 1 


Input


1


Output


1 

Note

In the first example, s=\{[1,1],[1,2]\}.

In the second example, s=\{[1,1,1],[1,1,2],[1,2,1],[1,2,2],[2,1,2],[1,2,3]\}.

In the third example, s=\{[1]\}.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b) { a = (a + b) % MOD; }
void mul(int64_t& a, int64_t b) { a = a * b % MOD; }
int64_t power_mod(int64_t num, int64_t power) {
  int64_t prod = 1;
  num %= MOD;
  while (power > 0) {
    if (power & 1) prod = prod * num % MOD;
    num = num * num % MOD;
    power >>= 1;
  }
  return prod;
}
int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {
  int64_t d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
int64_t inv_mod(int64_t a) {
  int64_t x, y;
  extgcd(a, MOD, x, y);
  return (MOD + x % MOD) % MOD;
}
vector<int64_t> fact, fact_inv;
void create_mod_tables(int num) {
  fact.assign(num + 1, 1);
  fact_inv.assign(num + 1, 1);
  for (int i = 1; i <= num; i++) fact[i] = fact[i - 1] * i % MOD;
  fact_inv[num] = inv_mod(fact[num]);
  for (int i = num; i > 0; i--) fact_inv[i - 1] = fact_inv[i] * i % MOD;
}
int64_t comb_mod(int n, int k) {
  return fact[n] * fact_inv[n - k] % MOD * fact_inv[k] % MOD;
}
int64_t perm_mod(int n, int k) { return fact[n] * fact_inv[n - k] % MOD; }
int main() {
  int N;
  cin >> N;
  create_mod_tables(N);
  static int64_t dp[5001][5001];
  dp[1][0] = 1;
  for (int i = 1; i < N; i++)
    for (int j = 0; j < i; j++) {
      add(dp[i + 1][j + 1], dp[i][j] * (i - j));
      add(dp[i + 1][j], dp[i][j] * (j + 1));
    }
  vector<int64_t> ans(N);
  for (int i = 1; i <= N; i++)
    for (int j = 0; j < i; j++) {
      add(ans[j], dp[i][j] * perm_mod(N, N - i));
    }
  for (auto a : ans) cout << a << " ";
  cout << endl;
  return 0;
}