#include <bits/stdc++.h>
using namespace std;
const int N = 3005, M = 998244353, K = 2e5 + 7;
long long w[K];
bool type[K];
long long PW = 0, NW = 0, m = 0, W = 0;
long long pdp[N][N], ndp[N][N];
bool vis[N][N];
long long power(long long a, long long p) {
  if (p == 0) return 1;
  long long ans = power(a, p / 2);
  ans = (ans * ans) % M;
  if (p % 2) ans = (ans * a) % M;
  return ans;
}
long long inverse(long long a) { return power(a, M - 2); }
long long inv[2 * N];
void pre() {
  for (int i = 0; i < 2 * N; i++) {
    int x = W + (i - N);
    if (x <= 0 || x >= M) continue;
    inv[i] = inverse(x);
  }
}
void calc(int p, int n) {
  if (vis[p][n]) return;
  vis[p][n] = 1;
  long long left = m - p - n;
  long long pw = PW + p;
  long long nw = NW - n;
  long long total = pw + nw;
  assert(nw >= 0);
  assert(pw < M);
  if (left == 0) {
    pdp[p][n] = pw;
    ndp[p][n] = nw;
    return;
  }
  if (pw) {
    calc(p + 1, n);
    pdp[p][n] = (pdp[p][n] + pw * pdp[p + 1][n]) % M;
    ndp[p][n] = (ndp[p][n] + pw * ndp[p + 1][n]) % M;
  }
  if (nw) {
    calc(p, n + 1);
    pdp[p][n] = (pdp[p][n] + nw * pdp[p][n + 1]) % M;
    ndp[p][n] = (ndp[p][n] + nw * ndp[p][n + 1]) % M;
  }
  long long ii = inv[total - W + N];
  pdp[p][n] = (pdp[p][n] * ii) % M;
  ndp[p][n] = (ndp[p][n] * ii) % M;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> type[i];
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
    if (type[i])
      PW += w[i];
    else
      NW += w[i];
  }
  W = PW + NW;
  pre();
  calc(0, 0);
  long long ipw = inverse(PW);
  long long inw = inverse(NW);
  for (int i = 1; i <= n; i++) {
    if (type[i]) {
      long long ans = (w[i] * pdp[0][0]) % M;
      ans = (ans * ipw) % M;
      cout << ans << "\n";
    } else {
      long long ans = (w[i] * ndp[0][0]) % M;
      ans = (ans * inw) % M;
      cout << ans << "\n";
    }
  }
}
