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 int maxn = 5010;
const long long mod = 998244353;
int n;
long long dp[maxn][maxn], f[maxn], Inv[maxn], ans[maxn];
inline long long _sum(long long i, long long j) {
  i += j;
  i %= mod;
  if (i < 0) i += mod;
  return i;
}
inline long long _mul(long long i, long long j) {
  i = (i * j) % mod;
  if (i < 0) i += mod;
  return i;
}
inline long long _pow(long long i, long long j) {
  long long ret = 1;
  for (; j; j /= 2, i = _mul(i, i))
    if (j & 1) ret = _mul(ret, i);
  return ret;
}
inline long long C(int i, int j) {
  if (j < i || i < 0 || j < 0 || j > n) return 0;
  long long ret = _mul(f[j], _mul(Inv[i], Inv[j - i]));
  return ret;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  f[0] = Inv[0] = 1;
  for (int y = 1; y <= n; y++)
    f[y] = _mul(f[y - 1], y), Inv[y] = _pow(f[y], mod - 2);
  for (int y = 0; y <= n; y++) dp[0][y] = 1;
  for (int y = 1; y <= n; y++)
    for (int x = 1; x < y; x++)
      dp[x][y] = _sum(_mul(dp[x][y - 1], x + 1), _mul(dp[x - 1][y - 1], y - x));
  for (int y = 1; y <= n; y++)
    for (int x = 0; x < y; x++)
      ans[x] = _sum(ans[x], _mul(C(y, n), _mul(f[n - y], dp[x][y])));
  for (int y = 0; y < n; y++) cout << ans[y] << ' ';
  return 0;
}