#include <bits/stdc++.h>
int a[262144], w[262144];
int mt(int a, int b) {
  if (b == 0) {
    return 1;
  }
  int c = mt(a, b >> 1);
  c = (long long)c * c % 998244353;
  if (b & 1) {
    c = (long long)c * a % 998244353;
  }
  return c;
}
int inv[8192];
int f[3005][3005], g[3005][3005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int s0 = 0, s1 = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
    if (!a[i]) {
      s0 += w[i];
    } else {
      s1 += w[i];
    }
  }
  for (int i = -m; i <= m; i++) {
    if (s0 + s1 + i <= 0) {
      continue;
    }
    inv[i + m] = mt(s0 + s1 + i, 998244351);
  }
  for (int i = 0; i <= m; i++) {
    f[m][i] = 1;
    g[m][i] = 1;
  }
  for (int i = m - 1; i >= 0; i--) {
    for (int j = 0; j <= i; j++) {
      int k = i - j;
      if (k > s0) {
        continue;
      }
      f[i][j] = (long long)f[i + 1][j + 1] * (s1 + j) % 998244353;
      f[i][j] += f[i + 1][j + 1];
      if (f[i][j] >= 998244353) {
        f[i][j] -= 998244353;
      }
      f[i][j] += (long long)f[i + 1][j] * (s0 - k) % 998244353;
      if (f[i][j] >= 998244353) {
        f[i][j] -= 998244353;
      }
      f[i][j] = (long long)f[i][j] * inv[j - k + m] % 998244353;
      if (k >= s0) {
        continue;
      }
      g[i][j] = (long long)g[i + 1][j + 1] * (s1 + j) % 998244353;
      g[i][j] += (long long)g[i + 1][j] * (s0 - k - 1) % 998244353;
      if (g[i][j] >= 998244353) {
        g[i][j] -= 998244353;
      }
      g[i][j] = (long long)g[i][j] * inv[j - k + m] % 998244353;
    }
  }
  for (int i = 0; i < n; i++) {
    int ans;
    if (a[i]) {
      ans = (long long)w[i] * f[0][0] % 998244353;
    } else {
      ans = (long long)w[i] * g[0][0] % 998244353;
    }
    printf("%d\n", ans);
  }
  return 0;
}
