#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b) { a = (a + b) % MOD; }
void mul(int64_t& a, int64_t b) { a = a * b % MOD; }
int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {
  int64_t d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
int64_t inv_mod(int64_t a) {
  int64_t x, y;
  extgcd(a, MOD, x, y);
  return (MOD + x % MOD) % MOD;
}
int64_t dp[3001][3001];
int main() {
  int N, M, A[200000], W[200000];
  cin >> N >> M;
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);
  for (int i = 0; i < N; i++) scanf("%d", &W[i]);
  int sum[2] = {0};
  for (int i = 0; i < N; i++) sum[A[i]] += W[i];
  dp[0][0] = 1;
  for (int i = 0; i < M; i++)
    for (int j = 0; j <= i; j++) {
      if (dp[i][j] == 0) continue;
      int s0 = sum[0] - j;
      int s1 = sum[1] + (i - j);
      int64_t iv = inv_mod(s0 + s1);
      int64_t C = dp[i][j] * iv % MOD;
      add(dp[i + 1][j + 1], C * s0 % MOD);
      add(dp[i + 1][j], C * s1 % MOD);
    }
  int64_t inv[2][3001];
  for (int k = 0; k < 2; k++)
    for (int i = 0; i <= M; i++) {
      int s = sum[k] + (k ? i : -i);
      if (s <= 0) continue;
      int64_t iv = inv_mod(s);
      if (k == 0) {
        inv[k][i] = (1 + MOD - iv) % MOD;
      } else {
        inv[k][i] = (1 + iv) % MOD;
      }
    }
  int64_t CC[2] = {0};
  for (int k = 0; k < 2; k++) {
    if (k == 0) {
      int64_t E = 1;
      for (int j = 0; j <= M; j++) {
        add(CC[0], E * dp[M][j]);
        if (sum[0] == j) break;
        mul(E, inv[0][j]);
      }
    } else {
      int64_t E = 1;
      for (int j = 0; j <= M; j++) {
        add(CC[1], E * dp[M][M - j]);
        mul(E, inv[1][j]);
      }
    }
  }
  for (int i = 0; i < N; i++) {
    int64_t ans = W[i] * CC[A[i]] % MOD;
    printf("%lld\n", ans);
  }
  return 0;
}
