#include <bits/stdc++.h>
const int maxn = 333333, maxm = 3333, mod = 998244353;
int n, m;
int a[maxn], w[maxn];
int ii[maxm * 4], *iv = ii + maxm * 2;
int f[maxm][maxm], g[maxm][maxm];
int ff, gg;
int wa, wb;
int In() {
  register int c, f, s;
  for (; c = getchar(), c != '-' && !isdigit(c);)
    ;
  for (s = (f = c == '-') ? 0 : c - '0'; c = getchar(), isdigit(c);)
    s = s * 10 + c - '0';
  return f ? -s : s;
}
int inv(register int x) {
  return x == 1 ? x : 1ll * inv(mod % x) * (mod - mod / x) % mod;
}
int main() {
  n = In(), m = In();
  for (register int i = 1; i <= n; ++i) a[i] = In();
  for (register int i = 1; i <= n; ++i)
    w[i] = In(), a[i] ? wa = (wa + w[i]) % mod : wb = (wb + w[i]) % mod;
  g[0][0] = f[0][0] = 1;
  for (register int i = -m; i <= m; ++i)
    if (wa + wb + i > 0) iv[i] = inv(0ll + wa + wb + i) % mod;
  for (register int i = 0; i <= m; ++i)
    for (register int j = 0; i + j <= m; ++j)
      if (i + j) {
        f[i][j] =
            ((i ? 1ll * f[i - 1][j] * (wa + i) % mod * iv[i - j - 1] : 0) +
             (j ? 1ll * f[i][j - 1] * (wb - j + 1) % mod * iv[i - j + 1] : 0)) %
            mod;
        g[i][j] =
            ((i ? 1ll * g[i - 1][j] * (wa + i - 1) % mod * iv[i - j - 1] : 0) +
             (j ? 1ll * g[i][j - 1] * (wb - j) % mod * iv[i - j + 1] : 0)) %
            mod;
      }
  for (register int i = 0; i <= m; ++i)
    ff = (ff + f[i][m - i]) % mod, gg = (gg + g[i][m - i]) % mod;
  for (register int i = 1; i <= n; ++i)
    printf("%lld\n", 1ll * w[i] * (a[i] ? ff : gg) % mod);
  return 0;
}
