#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const long long LINF = numeric_limits<long long>::max();
const long long mod = 998244353;
long long power(long long x, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) {
      res = (res * x) % mod;
    }
    x = (x * x) % mod;
    n /= 2;
  }
  return res;
}
long long inv(int x) { return power(x, mod - 2); }
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<long long> w(n);
  for (int i = 0; i < n; ++i) cin >> w[i];
  int w0 = 0, w1 = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i])
      w1 += w[i];
    else
      w0 += w[i];
  }
  vector<long long> d(m + 1, 0), dd(m + 1, 0);
  d[0] = 1;
  vector<int> invs(m);
  for (int i = 0; i < m; ++i) invs[i] = inv(i + w0 + w1);
  for (int i = 0; i < m; ++i) {
    dd.assign(m + 1, 0);
    for (int j = 0; j <= i; ++j) {
      int ww1 = w1 + j;
      int ww0 = w0 - (i - j);
      if (ww0 < 0) continue;
      dd[j + 1] = (dd[j + 1] + ((d[j] * ww1) % mod) * inv(ww0 + ww1)) % mod;
      dd[j] = (dd[j] + ((d[j] * ww0) % mod) * inv(ww0 + ww1)) % mod;
    }
    swap(d, dd);
  }
  dd.assign(d.begin(), d.end());
  reverse(dd.begin(), dd.end());
  vector<int> res(n);
  long long m1 = 0, m2 = 0;
  for (int i = 0; i <= m; ++i) {
    m1 = (m1 + ((d[i] * (w1 + i)) % mod) * inv(w1)) % mod;
    m2 = (m2 + ((dd[i] * (w0 - i)) % mod) * inv(w0)) % mod;
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1) {
      res[i] = (w[i] * m1) % mod;
    } else
      res[i] = (w[i] * m2) % mod;
    cout << res[i] << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();
  return 0;
}
