#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
int64_t powmo(int64_t a, int64_t b) {
  int64_t r = 1;
  for (; b; b >>= 1) {
    if (b & 1) r = r * a % MOD;
    a = a * a % MOD;
  }
  return r;
}
int64_t mdiv(int64_t a, int64_t b) { return a * powmo(b, MOD - 2) % MOD; }
bitset<300005> like;
int64_t w[300005];
int64_t ans[300005];
int64_t dp[3005][3005];
int32_t main() {
  {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  };
  int64_t n, m, t, add, sub, sum;
  add = sub = 0;
  cin >> n >> m;
  for (int64_t i = 0; i < n; i++) {
    cin >> t;
    like[i] = t;
  }
  for (int64_t i = 0; i < n; i++) {
    cin >> w[i];
    if (like[i])
      add += w[i];
    else
      sub += w[i];
  }
  dp[0][0] = 1;
  sum = add + sub;
  int64_t ia, is;
  ia = mdiv(1, add), is = mdiv(1, sub);
  for (int64_t x = 1; x <= m; x++) {
    for (int64_t i = x, j = 0; i >= 0 && j <= sub; i--, j++) {
      int64_t nowsum = sum + i - j;
      int64_t nowadd = add + i;
      int64_t nowsub = sub - j;
      dp[i][j] = 0;
      if (i > 0)
        dp[i][j] =
            (dp[i][j] + dp[i - 1][j] * mdiv(nowadd - 1, nowsum - 1) % MOD) %
            MOD;
      if (j > 0)
        dp[i][j] =
            (dp[i][j] + dp[i][j - 1] * mdiv(nowsub + 1, nowsum + 1) % MOD) %
            MOD;
    }
  }
  int64_t sa, ss;
  sa = ss = 0;
  for (int64_t i = m, j = 0; i >= 0 && j <= sub; i--, j++) {
    sa = (sa + i * dp[i][j]) % MOD;
    ss = (ss + MOD - j * dp[i][j] % MOD) % MOD;
  }
  for (int64_t i = 0; i < n; i++) {
    if (like[i])
      cout << (w[i] + w[i] * ia % MOD * sa) % MOD << '\n';
    else
      cout << (w[i] + w[i] * is % MOD * ss) % MOD << '\n';
  }
  return 0;
}
