#include <bits/stdc++.h>
using namespace std;
const int N = 1000005, M = 3005;
int n, m, a[N], w[N], s0, s1, s, f[M][M], g[M][M], inv[N];
inline int Min(const int p, const int q) { return p < q ? p : q; }
inline int ksm(register int x, register int L) {
  register int ans = 1;
  while (L)
    L& 1 ? ans = (0ll + ans) * x % 998244353 : 0, x = (0ll + x) * x % 998244353,
           L >>= 1;
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  register int i, j;
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (i = 1; i <= n; ++i)
    scanf("%d", &w[i]), s += w[i], a[i] ? s1 += w[i] : s0 += w[i];
  for (i = 0; i <= (m << 1); ++i) inv[i] = ksm(s + i - m, 998244353 - 2);
  for (i = m; ~i; --i)
    for (f[i][m - i] = g[i][m - i] = 1, j = Min(m - i - 1, s0); ~j; --j)
      f[i][j] = ((s1 + i + 1ll) * f[i + 1][j] + (s0 - j + 0ll) * f[i][j + 1]) %
                998244353 * inv[i - j + m] % 998244353,
      g[i][j] = ((s1 + i + 0ll) * g[i + 1][j] + (s0 - j - 1ll) * g[i][j + 1]) %
                998244353 * inv[i - j + m] % 998244353;
  for (i = 1; i <= n; ++i)
    printf("%d\n", (0ll + w[i]) * (a[i] ? f[0][0] : g[0][0]) % 998244353);
  return 0;
}
