#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int MAXN = 200010;
const int MAXM = 3010;
int exp(int x, int n) {
  int ret = 1;
  while (n) {
    if (n & 1) ret = 1LL * ret * x % mod;
    x = 1LL * x * x % mod;
    n >>= 1;
  }
  return ret;
}
int inv(int x) { return exp(x, mod - 2); }
int N, M;
int A[MAXN], W[MAXN], sum1, sum2;
int po[MAXM << 1];
pair<int, int> cc[MAXM][MAXM];
pair<int, int> dp(int p, int n) {
  if (p + n == M) return pair<int, int>(sum1 + p, sum2 - n);
  pair<int, int> &ret = cc[p][n];
  if (ret != pair<int, int>(-1, -1)) return ret;
  int s1 = sum1 + p;
  int s2 = sum2 - n;
  pair<int, int> t = dp(p + 1, n);
  pair<int, int> d = dp(p, n + 1);
  ret = pair<int, int>(0, 0);
  ret.first += 1LL * t.first * s1 % mod * po[MAXM + p - n] % mod;
  ret.second += 1LL * t.second * s1 % mod * po[MAXM + p - n] % mod;
  ret.first += 1LL * d.first * s2 % mod * po[MAXM + p - n] % mod;
  ret.second += 1LL * d.second * s2 % mod * po[MAXM + p - n] % mod;
  ret.first %= mod;
  ret.second %= mod;
  return ret;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> W[i];
    if (A[i])
      sum1 += W[i];
    else
      sum2 += W[i];
  }
  for (int i = -M; i <= M; i++) {
    if (0 < sum1 + sum2 + i) {
      po[MAXM + i] = inv(sum1 + sum2 + i);
    }
  }
  for (int i = 0; i <= M; i++)
    for (int j = 0; j <= M - i; j++) cc[i][j] = pair<int, int>(-1, -1);
  pair<int, int> t = dp(0, 0);
  int inv1 = inv(sum1);
  int inv2 = inv(sum2);
  for (int i = 0; i < N; i++) {
    if (A[i])
      cout << 1LL * t.first * W[i] % mod * inv1 % mod << '\n';
    else
      cout << 1LL * t.second * W[i] % mod * inv2 % mod << '\n';
  }
}
