#include <bits/stdc++.h>
using namespace std;
long long n, w[200021], pos[200021], sa, sb, f[3021][3021], g[3021][3021], m;
long long Q(long long a) {
  long long ans = 1;
  for (long long b = 998244353ll - 2; b; b >>= 1) {
    if (b & 1) ans = ans * a % 998244353ll;
    a = a * a % 998244353ll;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> pos[i];
  for (long long i = 1; i <= n; i++) {
    cin >> w[i];
    if (pos[i] == 0)
      sb = (sb + w[i]) % 998244353ll;
    else
      sa = (sa + w[i]) % 998244353ll;
  }
  for (long long i = 0; i <= m; i++) f[i][m - i] = g[i][m - i] = 1;
  for (long long a = m; a >= 0; a--) {
    for (long long b = m; b >= 0; b--) {
      if (a + b >= m) continue;
      f[a][b] = (sa + a + 1) * f[a + 1][b] % 998244353ll;
      f[a][b] = (f[a][b] + (sb - b) * f[a][b + 1]) % 998244353ll;
      g[a][b] = (sa + a) * g[a + 1][b] % 998244353ll;
      g[a][b] = (g[a][b] + (sb - b - 1) * g[a][b + 1]) % 998244353ll;
      f[a][b] = f[a][b] * Q(sa + sb + a - b) % 998244353ll;
      g[a][b] = g[a][b] * Q(sa + sb + a - b) % 998244353ll;
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (pos[i] == 0)
      cout << w[i] * g[0][0] % 998244353ll << endl;
    else
      cout << w[i] * f[0][0] % 998244353ll << endl;
  }
  return 0;
}
