#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
int n, m;
long long p, q;
int arr[200100];
long long w[200100];
long long po(long long a, long long n) {
  if (!n) return 1;
  long long t = po(a, n / 2);
  return t * t % MOD * (n % 2 ? a : 1) % MOD;
}
long long inv(long long a) { return po(a, MOD - 2); }
long long D[3010][3010];
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%d", &arr[i]);
  for (i = 0; i < n; i++) scanf("%lld", &w[i]);
  for (i = 0; i < n; i++) {
    if (!arr[i])
      p += w[i];
    else
      q += w[i];
  }
  p %= MOD;
  q %= MOD;
  int s;
  long long ans = 0, tans = 0;
  for (s = 0; s <= m; s++) {
    for (i = 0; i <= s; i++) {
      j = s - i;
      if (p - j < 0) continue;
      if (i == 0 && j == 0) {
        D[i][j] = 1;
      }
      if (s == m) {
        ans = (ans + D[i][j] * (p - j) % MOD) % MOD;
        tans = (tans + D[i][j] * (q + i) % MOD) % MOD;
        continue;
      }
      D[i][j + 1] =
          (D[i][j + 1] + D[i][j] * inv(p + q + i - j) % MOD * (p - j)) % MOD;
      D[i + 1][j] =
          (D[i + 1][j] + D[i][j] * inv(p + q + i - j) % MOD * (q + i)) % MOD;
    }
  }
  ans = ans * inv(p) % MOD;
  tans = tans * inv(q) % MOD;
  for (i = 0; i < n; i++) {
    if (!arr[i])
      printf("%lld\n", ans * w[i] % MOD);
    else
      printf("%lld\n", tans * w[i] % MOD);
  }
  return 0;
}
