#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int M = 2e5 + 10;
const int N = 3e3 + 10;
int n, m, a[M], w[M], sum[3], f[N][N], g[N][N], inv[N << 1];
int qpow(int a, int b) {
  int y = 1;
  for (; b; b >>= 1, a = (long long)a * a % mod)
    if (b & 1) y = (long long)y * a % mod;
  return y;
}
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]), sum[a[i]] += w[i];
  for (int i = max(0, m - sum[0]); i <= 2 * m; i++)
    inv[i] = qpow(sum[0] + sum[1] + i - m, mod - 2);
  for (int i = m; i >= 0; i--) {
    f[i][m - i] = g[i][m - i] = 1;
    for (int j = min(m - i - 1, sum[0]); j >= 0; j--) {
      f[i][j] = ((long long)f[i + 1][j] * (sum[1] + i + 1) % mod +
                 (long long)f[i][j + 1] * (sum[0] - j)) %
                mod * inv[m + i - j] % mod;
      g[i][j] = ((long long)g[i][j + 1] * (sum[0] - j - 1) % mod +
                 (long long)g[i + 1][j] * (sum[1] + i)) %
                mod * inv[m + i - j] % mod;
    }
  }
  for (int i = 1; i <= n; i++)
    printf("%d\n", int((long long)w[i] * (a[i] ? f[0][0] : g[0][0]) % mod));
  return 0;
}
