#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 2e5 + 5, M = 3005;
int n, m;
int w[N], a[N];
long long totw[2];
long long dp1[M][M], p, q;
long long ans[N];
long long qpow(long long x, long long y) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = ans * x % mod;
    y >>= 1;
    x = x * x % mod;
  }
  return ans;
}
inline long long inv(long long x) { return qpow(x, mod - 2); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &w[i]);
    totw[a[i]] += w[i];
  }
  dp1[0][0] = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= i; j++) {
      p = totw[0] - (i - 1 - j);
      q = totw[1] + j;
      if (p > 0) dp1[i][j] += dp1[i - 1][j] * p % mod * inv(p + q);
      p = totw[0] - (i - j);
      q = totw[1] + j - 1;
      if (j) dp1[i][j] += dp1[i - 1][j - 1] * q % mod * inv(p + q);
      dp1[i][j] %= mod;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1) {
      long long qw = w[i];
      ans[i] += dp1[m][0] * qw % mod;
      if (ans[i] >= mod) ans[i] -= mod;
      for (int j = 1; j <= m; j++) {
        qw = qw * (totw[1] + j - 1 - qw) % mod * inv(totw[1] + j - 1) +
             (qw + 1) * (qw) % mod * inv(totw[1] + j - 1);
        qw %= mod;
        if (qw < 0) qw += mod;
        ans[i] += dp1[m][j] * qw % mod;
        if (ans[i] >= mod) ans[i] -= mod;
      }
    } else {
      long long qw = w[i];
      ans[i] += dp1[m][m] * qw % mod;
      if (ans[i] >= mod) ans[i] -= mod;
      for (int j = 1; j <= m; j++) {
        qw = qw * (totw[0] - j + 1 - qw) % mod * inv(totw[0] - j + 1) +
             (qw - 1) * (qw) % mod * inv(totw[0] - j + 1);
        qw %= mod;
        if (qw < 0) qw += mod;
        ans[i] += dp1[m][m - j] * qw % mod;
        if (ans[i] >= mod) ans[i] -= mod;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}
