#include <bits/stdc++.h>
using namespace std;
const int p = 998244353;
inline int power(int x, int y) {
  int s = 1;
  while (y) {
    if (y & 1) s = (long long)s * x % p;
    x = (long long)x * x % p;
    y >>= 1;
  }
  return s;
}
const int N = 2e5 + 10, M = 3005;
int a[N], w[N], f[M][M], g[M][M];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  int sj = 0, sk = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", w + i);
    (a[i] ? sj : sk) += w[i];
  }
  for (int i = 0; i <= m; i++) f[i][m - i] = g[i][m - i] = 1;
  for (int i = m - 1; ~i; i--) {
    for (int j = 0, k = i; j <= i; j++, k--) {
      int inv = power(sj + j + sk - k, p - 2);
      f[j][k] = ((long long)(sj + j + 1) * f[j + 1][k] % p +
                 (long long)(sk - k) * f[j][k + 1] % p) *
                inv % p;
      g[j][k] = ((long long)(sj + j) * g[j + 1][k] % p +
                 (long long)(sk - k - 1) * g[j][k + 1] % p) *
                inv % p;
    }
  }
  for (int i = 1; i <= n; i++)
    printf("%d\n", (long long)(a[i] ? f : g)[0][0] * w[i] % p);
  return 0;
}
