#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline void read(T &x) {
  char ch = getchar();
  int f = 1;
  x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
template <typename T, typename... Args>
inline void read(T &x, Args &...args) {
  read(x), read(args...);
}
int n, m, t[200050], w[200050];
long long s[2];
long long dp[3050][3050];
long long fpow(long long x, long long y) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret = ret * x % 998244353;
    x = x * x % 998244353;
    y >>= 1;
  }
  return ret;
}
long long Inv(long long x) { return fpow(x % 998244353, 998244353 - 2); }
int main() {
  read(n, m);
  for (register int i = 1; i <= n; ++i) read(t[i]);
  for (register int i = 1; i <= n; ++i)
    read(w[i]), s[t[i]] = (s[t[i]] + w[i]) % 998244353;
  dp[0][0] = 1;
  for (register int i = 0; i <= m - 1; ++i) {
    for (register int j = 0; j <= i; ++j) {
      long long p = (s[1] + j) * Inv(s[0] + s[1] + j - i + j) % 998244353;
      dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * p) % 998244353;
      dp[i + 1][j] =
          (dp[i + 1][j] + dp[i][j] * (1 - p + 998244353)) % 998244353;
    }
  }
  long long E[2] = {0, 0};
  for (register int i = 0; i <= m; ++i) {
    E[1] = (E[1] + i * dp[m][i]) % 998244353;
    E[0] = (E[0] + (m - i) * dp[m][i]) % 998244353;
  }
  E[0] = (s[0] - E[0] + 998244353) % 998244353,
  E[1] = (E[1] + s[1]) % 998244353;
  for (register int i = 1; i <= n; ++i) {
    if (t[i] == 0)
      cout << E[0] * w[i] % 998244353 * Inv(s[0]) % 998244353 << endl;
    else
      cout << E[1] * w[i] % 998244353 * Inv(s[1]) % 998244353 << endl;
  }
  return 0;
}
