#include <bits/stdc++.h>
using namespace std;
template <typename __T>
inline void read(__T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
const int mod = 998244353;
long long qpow(long long a, long long b = mod - 2) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return ans;
}
int n, m;
int ty[200005], s[200005];
long long sm0, sm1;
int f[3005][3005], g[3005][3005];
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= n; i++) read(ty[i]);
  for (int i = 1; i <= n; i++) read(s[i]);
  for (int i = 1; i <= n; i++) {
    if (ty[i])
      sm1 += s[i];
    else
      sm0 += s[i];
  }
  f[0][0] = g[0][0] = 1;
  for (int i = 0; i < m; i++) {
    int mxx = min(1ll * i, sm0);
    for (int a = 0; a <= mxx; a++) {
      int b = i - a;
      long long fm = qpow(sm0 + sm1 - a + b);
      if (a < sm0) {
        f[a + 1][b] =
            (f[a + 1][b] + 1ll * f[a][b] * (sm0 - a - 1) % mod * fm) % mod;
        g[a + 1][b] =
            (g[a + 1][b] + 1ll * g[a][b] * (sm0 - a) % mod * fm) % mod;
      }
      f[a][b + 1] = (f[a][b + 1] + 1ll * f[a][b] * (sm1 + b) % mod * fm) % mod;
      g[a][b + 1] = (g[a][b + 1] + 1ll * g[a][b] * (sm1 + b) % mod * fm) % mod;
    }
  }
  long long e0 = 0;
  long long e1 = 0;
  for (int a = min(sm0, 1ll * m); a >= 0; a--) {
    int b = m - a;
    e0 = (e0 + f[a][b]) % mod;
    e1 = (e1 + 1ll * g[a][b] * b) % mod;
  }
  e1 = (e1 * qpow(sm1) + 1) % mod;
  for (int i = 1; i <= n; i++) {
    if (ty[i])
      printf("%lld\n", e1 * s[i] % mod);
    else
      printf("%lld\n", e0 * s[i] % mod);
  }
  return 0;
}
