#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 200005, M = 3003;
int n, m, a[N], w[N], f[M][M], g[M][M], inv[M << 1], sum[3];
inline long long qp(long long a, long long b) {
  if (b < 0) return b;
  if (b == 0) return 1;
  long long rt = 1;
  while (b) {
    if (b & 1) rt *= a;
    a = a * a;
    b >>= 1;
    rt %= mod, a %= mod;
  }
  return rt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int i, j;
  cin >> n >> m;
  for (i = 1; i <= n; ++i) cin >> a[i];
  for (i = 1; i <= n; ++i) {
    cin >> w[i];
    sum[a[i]] += w[i];
    sum[2] += w[i];
  }
  for (i = max(0, m - sum[0]); i <= m * 2; ++i)
    inv[i] = qp(sum[2] + i - m, mod - 2);
  for (i = m; ~i; --i) {
    f[i][m - i] = g[i][m - i] = 1;
    for (j = min(m - i - 1, sum[0]); ~j; --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 (i = 1; i <= n; ++i)
    cout << ((long long)w[i] * (a[i] ? f[0][0] : g[0][0])) % mod << endl;
  return 0;
}
