#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) {
  return os << '(' << pai.first << ' ' << pai.second << ')';
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
  cout << '[';
  for (int i = 0, _i = (((int)(v).size())); i < _i; i++) cout << v[i] << ",";
  cout << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> v) {
  cout << "{";
  for (auto p : v) cout << p << ",";
  cout << "}";
  return os;
}
template <typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
  cout << "{";
  for (auto p : v) cout << p << ",";
  cout << "}";
  return os;
}
template <typename T>
void get_max(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void get_min(T &a, T b) {
  a = min(a, b);
}
int N, M;
long long inv(long long v) {
  long long r = 1;
  for (int i = 998244353 - 2; i > 0; i >>= 1) {
    if (i & 1) r = r * v % 998244353;
    v = v * v % 998244353;
  }
  return r;
}
int A[200000];
int B[200000];
long long _dp[3001][7000];
long long &dp(int i, int j) { return _dp[i][j + 3500]; }
int main(void) {
  iostream::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cin >> N >> M;
  for (int i = 0, _i = (N); i < _i; i++) cin >> A[i];
  for (int i = 0, _i = (N); i < _i; i++) cin >> B[i];
  long long s1 = 0, s2 = 0;
  for (int i = 0, _i = (N); i < _i; i++) (A[i] ? s2 : s1) += B[i];
  dp(0, 0) = 1;
  for (int i = 0, _i = (M); i < _i; i++)
    for (int j = -i; j <= i; j += 2) {
      int v1 = (i - j) / 2, v2 = (i + j) / 2;
      dp(i + 1, j - 1) = (dp(i + 1, j - 1) +
                          dp(i, j) * (s1 - v1) % 998244353 * inv(s1 + s2 + j)) %
                         998244353;
      dp(i + 1, j + 1) = (dp(i + 1, j + 1) +
                          dp(i, j) * (s2 + v2) % 998244353 * inv(s1 + s2 + j)) %
                         998244353;
    }
  long long t1 = 0, t2 = 0;
  for (int i = -M; i <= M; i += 2) {
    0;
    int v1 = (M - i) / 2, v2 = (M + i) / 2;
    t1 = (t1 + dp(M, i) * (s1 - v1)) % 998244353;
    t2 = (t2 + dp(M, i) * (s2 + v2)) % 998244353;
  }
  for (int i = 0, _i = (N); i < _i; i++) {
    if (!A[i])
      cout << t1 * B[i] % 998244353 * inv(s1) % 998244353 << '\n';
    else
      cout << t2 * B[i] % 998244353 * inv(s2) % 998244353 << '\n';
  }
}
