#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch - '0' < 0 || ch - '0' > 9) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch - '0' >= 0 && ch - '0' <= 9) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, A, B;
int a[200010], w[200010];
int quick_pow(int x, int p) {
  int an = 1;
  int po = x;
  while (p) {
    if (p & 1) an = 1ll * an * po % 998244353;
    po = 1ll * po * po % 998244353;
    p >>= 1;
  }
  return an;
}
int f[3010][3010], g[3010][3010];
int inv[3010 * 2];
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) w[i] = read();
  for (int i = 1; i <= n; i++) {
    A += (a[i] == 1) * w[i];
    A %= 998244353;
    B += (a[i] == 0) * w[i];
    B %= 998244353;
  }
  for (int i = 1; i <= 2 * m; i++)
    inv[i] = quick_pow(A + B + i - m, 998244353 - 2);
  for (int i = m; i >= 0; i--) {
    f[i][m - i] = g[i][m - i] = 1;
    for (int j = min(m - i - 1, B); j >= 0; j--) {
      f[i][j] = (1ll * f[i + 1][j] * (A + i + 1) % 998244353 * inv[i - j + m] %
                     998244353 +
                 1ll * f[i][j + 1] * (B - j) % 998244353 * inv[i - j + m] %
                     998244353) %
                998244353;
      g[i][j] = (1ll * g[i + 1][j] * (A + i) % 998244353 * inv[i - j + m] %
                     998244353 +
                 1ll * g[i][j + 1] * (B - j - 1) % 998244353 * inv[i - j + m] %
                     998244353) %
                998244353;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1)
      printf("%d\n", 1ll * w[i] * f[0][0] % 998244353);
    else
      printf("%d\n", 1ll * w[i] * g[0][0] % 998244353);
  }
  return 0;
}
