#include <bits/stdc++.h>
using namespace std;
long long powmod(long long x, long long y = 998244353 - 2,
                 long long p = 998244353) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = ans * x % p;
    x = x * x % p;
    y >>= 1;
  }
  return ans;
}
int n, m;
long long W[200010];
int A[200010];
long long F[3010][6010];
void add(long long &x, long long y) { x = (x + y) % 998244353; }
long long rev[6010];
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("%lld", &W[i]);
  long long totw = 0, totg = 0, totb = 0;
  for (int i = 1; i <= n; i++) {
    totw += W[i];
    if (A[i])
      totg += W[i];
    else
      totb += W[i];
  }
  for (int i = -m; i <= m; i++) rev[i + m] = powmod(totw + i);
  F[0][m] = 1;
  for (int i = 0; i < m; i++)
    for (int j = m - i; j <= m + i; j++)
      if (F[i][j]) {
        long long g = totg + (i + (j - m)) / 2, b = totb - (i - (j - m)) / 2;
        add(F[i + 1][j + 1], F[i][j] * rev[j] % 998244353 * g);
        add(F[i + 1][j - 1], F[i][j] * rev[j] % 998244353 * b);
      }
  long long Eg = 0, Eb = 0;
  for (int i = -m; i <= m; i++) {
    long long pr = F[m][i + m];
    long long g = totg + (m + i) / 2, b = totb - (m - i) / 2;
    Eg = (Eg + g * pr % 998244353) % 998244353;
    Eb = (Eb + b * pr % 998244353) % 998244353;
  }
  long long rtotg = powmod(totg), rtotb = powmod(totb);
  long long tmpg = (Eg - totg) * rtotg % 998244353;
  long long tmpb = (totb - Eb) * rtotb % 998244353;
  for (int i = 1; i <= n; i++)
    if (A[i] == 0) {
      long long tmp = (1 - tmpb) * W[i] % 998244353;
      printf("%lld\n", (tmp % 998244353 + 998244353) % 998244353);
    } else {
      long long tmp = (1 + tmpg) * W[i] % 998244353;
      printf("%lld\n", (tmp % 998244353 + 998244353) % 998244353);
    }
  return 0;
}
