#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 3005;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> w(n + 1);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> w[i];
  int sumgood = 0, sumbad = 0;
  for (int i = 0; i < n; i++) {
    if (a[i])
      sumgood += w[i];
    else
      sumbad += w[i];
  }
  int sum = sumgood + sumbad;
  function<int(int, int)> power;
  power = [&](int num, int mul) {
    int res = 1;
    while (mul > 0) {
      if ((mul & 1)) res = 1ll * num * res % mod;
      num = 1ll * num * num % mod;
      mul = mul >> 1;
    }
    return res;
  };
  vector<vector<int>> dp(m + 1, vector<int>(m + 1));
  dp[0][0] = 1;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m - i; j++) {
      if (dp[i][j] == 0) continue;
      int good = sumgood + i, bad = sumbad - j;
      dp[i + 1][j] = (dp[i + 1][j] + 1ll * good * power(good + bad, mod - 2) %
                                         mod * dp[i][j] % mod) %
                     mod;
      dp[i][j + 1] = (dp[i][j + 1] + 1ll * bad * power(good + bad, mod - 2) %
                                         mod * dp[i][j] % mod) %
                     mod;
    }
  int goodexp = 0, badexp = 0;
  for (int i = 0; i <= m; i++) {
    goodexp = 1ll * (goodexp + 1ll * dp[i][m - i] * i % mod) % mod;
    badexp = 1ll * (badexp + 1ll * dp[m - i][i] * i % mod) % mod;
  }
  for (int i = 0; i < n; i++) {
    int ans;
    if (a[i])
      ans = 1ll * w[i] * (1ll + 1ll * goodexp * power(sumgood, mod - 2) % mod) %
            mod;
    else
      ans = 1ll * w[i] *
            ((1ll - 1ll * badexp * power(sumbad, mod - 2) % mod + mod) % mod) %
            mod;
    cout << ans << "\n";
  }
  return 0;
}
