#include <bits/stdc++.h>
using namespace std;
const int MD = 998244353;
const int MX = 3005;
void add(int& a, int b) {
  a += b;
  if (a >= MD) a -= MD;
}
int mod_mult(long long a, long long b) { return (a * b) % MD; }
int exp(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mod_mult(res, a);
    a = mod_mult(a, a);
    b /= 2;
  }
  return res;
}
int inv(int a) { return exp(a, MD - 2); }
int F[MX][MX], G[MX][MX];
int like[200005], w[200005];
int main() {
  int n, m;
  ignore = scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) ignore = scanf("%d", like + i);
  int A = 0, B = 0;
  for (int i = 0; i < n; i++) {
    ignore = scanf("%d", w + i);
    if (like[i])
      A += w[i];
    else
      B += w[i];
  }
  for (int a = 0; a <= m; a++) {
    int b = m - a;
    F[a][b] = 1;
    G[a][b] = 1;
  }
  for (int sum = m - 1; sum >= 0; sum--) {
    for (int a = 0; a <= sum; a++) {
      int b = sum - a;
      int quo = inv(A + a + B - b);
      add(F[a][b], mod_mult(A + a + 1, mod_mult(F[a + 1][b], quo)));
      add(F[a][b], mod_mult(B - b, mod_mult(F[a][b + 1], quo)));
      add(G[a][b], mod_mult(B - b - 1, mod_mult(G[a][b + 1], quo)));
      add(G[a][b], mod_mult(A + a, mod_mult(G[a + 1][b], quo)));
    }
  }
  for (int i = 0; i < n; i++) {
    int res;
    if (like[i]) {
      res = mod_mult(w[i], F[0][0]);
    } else {
      res = mod_mult(w[i], G[0][0]);
    }
    printf("%d\n", res);
  }
}
