#include <bits/stdc++.h>
using namespace std;
const int64_t mod = 998244353;
inline int64_t sub(int64_t a, int64_t b) { return a < b ? a - b + mod : a - b; }
inline int64_t add(int64_t a, int64_t b) {
  return a + b < mod ? a + b : a + b - mod;
}
inline int64_t mul(int64_t a, int64_t b) { return a * b % mod; }
inline int64_t inv(int64_t x) {
  return x == int64_t(1) ? int64_t(1) : mul(inv(mod % x), mod - mod / x);
}
inline int64_t divv(int64_t a, int64_t b) { return mul(a, inv(b)); }
const int maxn = 1 << 18;
const int maxm = 1 << 12;
int64_t dp[maxm][maxm], w[maxn], cnt[2];
int n, m, a[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> m;
  for (int i = 0; i != n; ++i) cin >> a[i];
  for (int i = 0; i != n; ++i) {
    cin >> w[i];
    cnt[a[i]] += w[i];
  }
  dp[0][0] = 1;
  for (int i = 0; i != m; ++i)
    for (int j = 0; j <= i; ++j)
      if (j <= cnt[0]) {
        dp[j + 1][i - j] = add(
            dp[j + 1][i - j],
            mul(dp[j][i - j], divv(cnt[0] - j, cnt[0] + cnt[1] + i - j - j)));
        dp[j][i - j + 1] =
            add(dp[j][i - j + 1],
                mul(dp[j][i - j],
                    divv(cnt[1] + i - j, cnt[0] + cnt[1] + i - j - j)));
      }
  for (int i = 0; i <= 3; ++i) {
    for (int j = 0; j <= 3; ++j) cerr << dp[i][j] << ' ';
    cerr << endl;
  }
  int64_t tot[2] = {0};
  for (int i = 1; i <= m; ++i) {
    tot[0] = add(tot[0], mul(i, dp[i][m - i]));
    tot[1] = add(tot[1], mul(i, dp[m - i][i]));
  }
  for (int i = 0; i != n; ++i) {
    if (a[i])
      cout << add(w[i], mul(tot[a[i]], divv(w[i], cnt[a[i]]))) << '\n';
    else
      cout << sub(w[i], mul(tot[a[i]], divv(w[i], cnt[a[i]]))) << '\n';
  }
}
