#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353LL;
inline long long _a(long long a, long long b) { return (a + b) % MOD; }
inline long long _s(long long a, long long b) { return (a - b + MOD) % MOD; }
inline long long _m(long long a, long long b) { return (a * b) % MOD; }
inline long long pow(long long a, long long p) {
  long long ret = 1LL;
  while (p) {
    if (p & 1LL) ret = _m(ret, a);
    a = _m(a, a), p >>= 1LL;
  }
  return ret;
}
inline long long inv(long long x) { return pow(x, MOD - 2); }
int N, M;
bool lik[200000];
long long w[200000], sl = 0, sdl = 0;
long long dp[2][3001][3001];
long long dinv[10001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> lik[i];
  for (int i = 0; i < N; i++) {
    cin >> w[i];
    if (lik[i])
      sl += w[i];
    else
      sdl += w[i];
  }
  for (int i = 0; i < 10001; i++) dinv[i] = inv(_s(sl + sdl + i, 5000));
  for (int f = 0; f < 2; f++)
    for (int i = M; i >= 0; i--)
      for (int j = M - i; j >= 0; j--) {
        long long &ans = dp[f][i][j];
        if (M - i - j <= 0)
          ans = 1LL;
        else {
          long long cl = _a(sl, i), cdl = _s(sdl, j);
          if (f == 0)
            ans = _m(dinv[i - j + 5000LL],
                     _a(_m(cdl - 1, dp[f][i][j + 1]), _m(cl, dp[f][i + 1][j])));
          else
            ans = _m(dinv[i - j + 5000LL],
                     _a(_m(cl + 1, dp[f][i + 1][j]), _m(cdl, dp[f][i][j + 1])));
        }
      }
  for (int i = 0; i < N; i++) {
    cout << _m(w[i], dp[lik[i]][0][0]) << "\n";
  }
}
