#include <bits/stdc++.h>
using namespace std;
long long modpow(long long x, int p = 998244353 - 2) {
  if (p == 0) return 1;
  long long tmp = modpow(x, p / 2);
  tmp = tmp * tmp % 998244353;
  if (p % 2 == 1) tmp = tmp * x % 998244353;
  return tmp;
}
int N, M;
int A[202020], W[202020];
vector<int> pos, posloc, nega, negaloc;
long long ans[202020];
long long sum(vector<int> &v) {
  long long ret = 0;
  for (int x : v) ret += x;
  return ret;
}
long long dp[3030][3030];
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i) scanf("%d", A + i);
  for (int i = 0; i < N; ++i) scanf("%d", W + i);
  for (int i = 0; i < N; ++i) {
    if (A[i] == 0) {
      nega.push_back(W[i]);
      negaloc.push_back(i);
    } else {
      pos.push_back(W[i]);
      posloc.push_back(i);
    }
  }
  long long negasum = sum(nega), possum = sum(pos);
  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;
      long long ng = negasum - i, ps = possum + j;
      ((dp[i + 1][j]) =
           ((dp[i + 1][j]) +
            (dp[i][j] * ng % 998244353 * modpow(ng + ps)) % 998244353) %
           998244353);
      ((dp[i][j + 1]) =
           ((dp[i][j + 1]) +
            (dp[i][j] * ps % 998244353 * modpow(ng + ps)) % 998244353) %
           998244353);
    }
  }
  long long pos_expv = 0, nega_expv = 0;
  for (int i = 0; i <= M; ++i) {
    ((nega_expv) = ((nega_expv) + (dp[i][M - i] * i % 998244353) % 998244353) %
                   998244353);
    ((pos_expv) =
         ((pos_expv) + (dp[i][M - i] * (M - i) % 998244353) % 998244353) %
         998244353);
  }
  for (int i = 0; i < pos.size(); ++i) {
    ans[posloc[i]] =
        pos[i] * (1 + pos_expv * modpow(possum) % 998244353) % 998244353;
  }
  for (int i = 0; i < nega.size(); ++i) {
    ans[negaloc[i]] =
        nega[i] * (1 + 998244353 - nega_expv * modpow(negasum) % 998244353) %
        998244353;
  }
  for (int i = 0; i < N; ++i) printf("%lld\n", ans[i]);
  return 0;
}
