#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 998244353, M = 3e3 + 10;
int ksm(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = (long long)ans * x % mod;
    x = (long long)x * x % mod;
    y >>= 1;
  }
  return ans;
}
int a[N], w[N], f[M][M], g[M][M], inv[M << 1], sum[3];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) {
    scanf("%d", w + i);
    sum[a[i]] += w[i];
    sum[2] += w[i];
  }
  for (int i = 0; i <= 2 * m; i++) inv[i] = ksm(sum[2] + i - m, mod - 2);
  for (int i = m; i >= 0; i--) {
    f[i][m - i] = g[i][m - i] = 1;
    for (int j = m - i - 1; j >= 0; j--) {
      f[i][j] = (1LL * (sum[1] + i + 1) * f[i + 1][j] +
                 1LL * (sum[0] - j) * f[i][j + 1]) %
                mod * inv[i - j + m] % mod;
      g[i][j] = (1LL * (sum[1] + i) * g[i + 1][j] +
                 1LL * (sum[0] - j - 1) * g[i][j + 1]) %
                mod * inv[i - j + m] % mod;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i])
      printf("%I64d\n", 1LL * w[i] * f[0][0] % mod);
    else
      printf("%I64d\n", 1LL * w[i] * g[0][0] % mod);
  }
  return 0;
}
