#include <bits/stdc++.h>
const int MOD = 998244353;
const int kN = 3000 + 5;
int n, m;
int a[200000 + 5], w[200000 + 5];
int f[kN][kN], g[kN][kN];
int inv(int x) {
  return x == 1 ? 1 : (MOD - MOD / x) * 1LL * inv(MOD % x) % MOD;
}
int main() {
  scanf("%d%d", &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 SA = 0, SB = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1)
      SA += w[i];
    else
      SB += w[i];
  }
  for (int i = m; i >= 0; --i) {
    for (int j = m - i; j >= 0; --j) {
      if (i + j == m) {
        f[i][j] = g[i][j] = 1;
      } else if (SA + i + SB - j > 0 && SB >= j) {
        int inv_dom = inv(SA + i + SB - j);
        f[i][j] = (f[i + 1][j] * 1LL * (SA + i + 1) % MOD +
                   f[i][j + 1] * 1LL * (SB - j) % MOD) *
                  inv_dom % MOD;
        if (SB - j > 0) {
          g[i][j] = (g[i + 1][j] * 1LL * (SA + i) % MOD +
                     g[i][j + 1] * 1LL * (SB - j - 1) % MOD) *
                    inv_dom % MOD;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1)
      printf("%d\n", f[0][0] * 1LL * w[i] % MOD);
    else
      printf("%d\n", g[0][0] * 1LL * w[i] % MOD);
  }
}
