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;
int n;
int Wl, Wl2, w[300005], lg[300005], inv[300005], fac[300005], invf[300005];
int Pow(int b, int k) {
  int r = 1;
  for (; k; k >>= 1, b = 1ll * b * b % 998244353)
    if (k & 1) r = 1ll * r * b % 998244353;
  return r;
}
void init(int n) {
  for (Wl = inv[0] = inv[1] = invf[0] = invf[1] = fac[0] = fac[1] = 1;
       n >= Wl << 1; Wl <<= 1)
    ;
  int pw = Pow(3, (998244353 - 1) / (Wl2 = Wl << 1));
  w[Wl] = 1;
  for (int i = (Wl + 1), LIM = (Wl2 - 1); i <= LIM; i++)
    w[i] = 1ll * w[i - 1] * pw % 998244353;
  for (int i = (Wl - 1), LIM = (1); i >= LIM; i--) w[i] = w[i << 1];
  for (int i = (2), LIM = (Wl2); i <= LIM; i++)
    inv[i] = 1ll * (998244353 - 998244353 / i) * inv[998244353 % i] % 998244353,
    fac[i] = 1ll * fac[i - 1] * i % 998244353,
    invf[i] = 1ll * invf[i - 1] * inv[i] % 998244353, lg[i] = lg[i >> 1] + 1;
}
void NTT(int *A, int n, int tp) {
  static int r[300005];
  static unsigned long long a[300005];
  if (tp ^ 1) reverse(A + 1, A + n);
  for (int i = (0), LIM = (n - 1); i <= LIM; i++)
    r[i] = r[i >> 1] >> 1 | (i & 1) << lg[n] - 1,
    a[i] = (A[r[i]] += A[r[i]] >> 31 & 998244353);
  for (int L = 1; L < n; L <<= 1)
    for (int s = 0, L2 = L << 1; s < n; s += L2)
      for (int k = s, x = L, t; k < s + L; k++, x++)
        t = w[x] * a[k + L] % 998244353, a[k + L] = a[k] - t + 998244353,
        a[k] += t;
  for (int i = (0), LIM = (n - 1); i <= LIM; i++) A[i] = a[i] % 998244353;
  if (tp ^ 1)
    for (int i = (0), LIM = (n - 1); i <= LIM; i++)
      A[i] = 1ll * A[i] * inv[n] % 998244353;
}
void Mul(int *A, int *B, int *C, int n, int m, int clr = -1) {
  static int st[2][300005];
  int L = 1 << lg[n + m] + 1;
  for (int i = (0), LIM = (L - 1); i <= LIM; i++)
    st[0][i] = i <= n ? A[i] : 0, st[1][i] = i <= m ? B[i] : 0;
  NTT(st[0], L, 1), NTT(st[1], L, 1);
  for (int i = (0), LIM = (L - 1); i <= LIM; i++)
    C[i] = 1ll * st[0][i] * st[1][i] % 998244353;
  NTT(C, L, -1);
  if (clr != -1)
    for (int i = (clr + 1), LIM = (n + m); i <= LIM; i++) C[i] = 0;
}
void Inv(int *A, int *B, int n) {
  B[B[1] = 0] = Pow(A[0], 998244353 - 2);
  static int t[300005];
  for (int k = 2, L = 4; k < (n << 1); k <<= 1, L <<= 1) {
    for (int i = (0), LIM = (L - 1); i <= LIM; i++)
      t[i] = i < k ? A[i] : B[i] = 0;
    NTT(t, L, 1), NTT(B, L, 1);
    for (int i = (0), LIM = (L - 1); i <= LIM; i++)
      B[i] = B[i] * (2 - 1ll * t[i] * B[i] % 998244353) % 998244353;
    NTT(B, L, -1);
    for (int i = (min(n, k)), LIM = (L - 1); i <= LIM; i++) B[i] = 0;
  }
}
void Ln(int *A, int *B, int n) {
  static int t[300005];
  Inv(A, B, n);
  int L = 1 << lg[2 * n - 2] + 1;
  for (int i = (0), LIM = (L - 1); i <= LIM; i++)
    t[i] = i < n - 1 ? A[i + 1] * (i + 1ll) % 998244353 : B[i] = 0;
  NTT(t, L, 1), NTT(B, L, 1);
  for (int i = (0), LIM = (L - 1); i <= LIM; i++)
    t[i] = 1ll * t[i] * B[i] % 998244353;
  NTT(t, L, -1);
  B[0] = 0;
  for (int i = (1), LIM = (L - 1); i <= LIM; i++)
    B[i] = i < n ? 1ll * t[i - 1] * inv[i] % 998244353 : 0;
}
void Exp(int *A, int *B, int n) {
  static int t[300005];
  B[B[1] = 0] = 1;
  for (int k = 2, L = 4; k < (n << 1); k <<= 1, L <<= 1) {
    Ln(B, t, k);
    for (int i = (0), LIM = (L - 1); i <= LIM; i++)
      t[i] = i < k ? (i == 0) + A[i] - t[i] : B[i] = 0;
    NTT(t, L, 1), NTT(B, L, 1);
    for (int i = (0), LIM = (L - 1); i <= LIM; i++)
      B[i] = 1ll * B[i] * t[i] % 998244353;
    NTT(B, L, -1);
    for (int i = (min(n, k)), LIM = (L - 1); i <= LIM; i++) B[i] = 0;
  }
}
int H[300005], Hd[300005], Hi[300005], Hn1[300005], A[300005], B[300005],
    C[300005], D[300005], E[300005], Lx[300005], Rx[300005];
int S[300005], G[300005], F[300005], ans[300005], P[300005];
int main() {
  scanf("%d", &n);
  init((n + 10) << 1);
  A[0] = A[1] = 1;
  Ln(A, B, n + 4);
  for (int i = (0), LIM = (n + 10); i <= LIM; i++) B[i] = B[i + 1];
  Inv(B, H, n + 10);
  for (int i = (0), LIM = (n + 10); i <= LIM; i++)
    Hd[i] = H[i + 1] * (i + 1ll) % 998244353;
  Ln(H, C, n + 10);
  for (int i = (0), LIM = (n + 10); i <= LIM; i++)
    C[i] = 1ll * C[i] * (n + 1) % 998244353;
  Exp(C, Hn1, n + 10);
  for (int i = (0), LIM = (n + 10); i <= LIM; i++)
    D[i] = (998244353 - H[i + 1]) % 998244353;
  Inv(D, Hi, n + 10);
  Mul(Hn1, Hi, Rx, n + 10, n + 10);
  for (int i = (0), LIM = (n + 10); i <= LIM; i++) Rx[i] = Rx[i + 1];
  Mul(Hi, Hi, Hi, n + 10, n + 10);
  Mul(Hi, Hd, Lx, n + 10, n + 10);
  Mul(Lx, Hn1, Lx, n + 10, n + 10);
  for (int i = (0), LIM = (n + 10); i <= LIM; i++) Lx[i] = Lx[i + 2];
  for (int i = (0), LIM = (n); i <= LIM; i++) {
    S[i] = (Rx[n + 1 - i] * 1ll * i % 998244353 + (i <= n ? Lx[n - i] : 0)) *
           inv[n + 1] % 998244353;
  }
  reverse(S, S + n + 2);
  for (int i = (0), LIM = (n + 10); i <= LIM; i++)
    G[i] = 998244353 - invf[i + 2];
  Inv(G, E, n + 10);
  for (int i = (0), LIM = (n + 10); i <= LIM; i++) E[i] = E[i + 1];
  for (int i = (0), LIM = (n + 1); i <= LIM; i++)
    S[i] = (E[i] - S[i]) % 998244353;
  S[0] = n;
  for (int i = (0), LIM = (n + 1); i <= LIM; i++)
    S[i] = 1ll * S[i] * fac[i] % 998244353;
  for (int i = (0), LIM = (n); i <= LIM; i++)
    F[i] = (n - i & 1 ? -1 : 1) * invf[n - i];
  Mul(S, F, P, n, n);
  for (int i = (0), LIM = (n); i <= LIM; i++)
    ans[i] = 1ll * P[n + i] * fac[n] % 998244353 * invf[i] % 998244353;
  for (int i = (0), LIM = (n - 1); i <= LIM; i++)
    printf("%d%c", (ans[i] + 998244353) % 998244353, " \n"[i == n]);
}