#include <bits/stdc++.h>
using namespace std;
long long inv(long long a, long long mod) {
  long long b = mod, p = 1, q = 0;
  while (b) {
    long long c = a / b, d = a;
    a = b;
    b = d % b;
    d = p;
    p = q;
    q = d - c * q;
  }
  return (p + mod) % mod;
}
map<pair<int, int>, pair<long long, long long>> mp;
pair<long long, long long> sol(int w0, int w1, int m) {
  pair<long long, long long> res;
  long long mod = 998244353;
  pair<int, int> key = make_pair(w0, w1);
  if (mp.find(key) != mp.end()) return mp[key];
  if (m == 0) {
    res = make_pair(w0, w1);
  } else {
    long long sum = w0 + w1;
    long long isum = inv(sum, mod);
    pair<long long, long long> p0 = sol(w0 - 1, w1, m - 1),
                               p1 = sol(w0, w1 + 1, m - 1);
    long long t0 =
        w0 * isum % mod * p0.first % mod + w1 * isum % mod * p1.first % mod;
    long long t1 =
        w0 * isum % mod * p0.second % mod + w1 * isum % mod * p1.second % mod;
    res = make_pair(t0 % mod, t1 % mod);
  }
  mp[key] = res;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<long long> a(n), w(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> w[i];
  long long mod = 998244353;
  vector<long long> res(n);
  int w0 = 0, w1 = 0;
  for (int j = 0; j < n; j++) {
    if (a[j] == 0)
      w0 = (w0 + w[j]) % mod;
    else
      w1 = (w1 + w[j]) % mod;
  }
  pair<long long, long long> p0 = sol(w0, w1, m);
  for (int i = 0; i < n; i++) {
    if (a[i]) {
      res[i] = w[i] + w[i] * inv(w1, mod) % mod * (p0.second - w1 + mod) % mod;
    } else {
      res[i] =
          w[i] + mod - w[i] * inv(w0, mod) % mod * (w0 - p0.first + mod) % mod;
    }
    cout << res[i] % mod << "\n";
  }
  return 0;
}
