#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[300005], w[300005];
long long ksm(long long a, long long b) {
  if (!b) return 1;
  long long ns = ksm(a, b >> 1);
  ns = ns * ns % 998244353;
  if (b & 1) ns = ns * a % 998244353;
  return ns;
}
long long dp[3005][3005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long S[2] = {0, 0};
  for (int i = 1; i <= n; i++)
    scanf("%d", &w[i]), S[a[i]] += w[i], S[a[i]] %= 998244353;
  long long f[2] = {S[0], S[1]};
  dp[1][0] = 1;
  for (int i = 1; i <= m; i++)
    for (int j = 0; j <= i; j++) {
      long long n1 = S[1] + j, n2 = S[0] - (i - 1 - j);
      if (!dp[i][j]) continue;
      long long bk = ksm((n1 + n2) % 998244353, 998244353 - 2);
      n1 = n1 * bk % 998244353, n2 = n2 * bk % 998244353;
      dp[i + 1][j] += n2 * dp[i][j], dp[i + 1][j] %= 998244353;
      dp[i + 1][j + 1] += n1 * dp[i][j], dp[i + 1][j + 1] %= 998244353;
    }
  for (int j = 0; j <= m + 1; j++)
    f[1] += dp[m + 1][j] * j, f[1] %= 998244353, f[0] -= dp[m + 1][j] * (m - j),
        f[0] %= 998244353;
  S[0] = ksm(S[0], 998244353 - 2);
  S[1] = ksm(S[1], 998244353 - 2);
  for (int i = 1; i <= n; i++) {
    long long ns = f[a[i]] * S[a[i]] % 998244353 * w[i] % 998244353;
    if (ns < 0) ns += 998244353;
    printf("%lld\n", ns);
  }
  return 0;
}
