#include <bits/stdc++.h>
using namespace std;
int n, m, a[200010], w[200010], f[3010][3010], g[3010][3010], inv[3010 * 2],
    sum[3];
const int mod = 998244353;
int getInverse(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = (long long)ret * x % mod;
    x = (long long)x * x % mod;
    y >>= 1;
  }
  return ret;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    cin >> w[i];
    sum[a[i]] += w[i];
    sum[2] += w[i];
  }
  for (int i = max(0, m - sum[0]); i <= 2 * m; ++i)
    inv[i] = getInverse(sum[2] + i - m, mod - 2);
  for (int i = m; i >= 0; --i) {
    f[i][m - i] = g[i][m - i] = 1;
    for (int j = min(m - i - 1, sum[0]); j >= 0; --j) {
      f[i][j] = ((long long)(sum[1] + i + 1) * f[i + 1][j] +
                 (long long)(sum[0] - j) * f[i][j + 1]) %
                mod * inv[i - j + m] % mod;
      g[i][j] = ((long long)(sum[1] + i) * g[i + 1][j] +
                 (long long)(sum[0] - j - 1) * g[i][j + 1]) %
                mod * inv[i - j + m] % mod;
    }
  }
  for (int i = 1; i <= n; ++i)
    cout << ((long long)w[i] * (a[i] ? f[0][0] : g[0][0])) % mod << endl;
  return 0;
}
