#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vint = vector<int>;
constexpr ll MOD = 998244353LL;
constexpr int MAX_ADD = 3000 + 5;
ll ppow(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % MOD;
    }
    b /= 2;
    a = (a * a) % MOD;
  }
  return ans;
}
vector<ll> mods;
ll modinv(ll k) { return ppow(k, MOD - 2); }
class solver {
 private:
  int n, m;
  vector<int> likes;
  vector<int> weights;
  ll all_sum;
  ll all_likes;
  ll all_unlikes;
  vector<ll> invs;
  vector<ll> cc[2][2];
  ll dp(int like, int ld, int ost) {
    if (abs(ld) > MAX_ADD) {
      return 0;
    }
    if (ost == 0) {
      return 1;
    }
    int pld;
    if (ld >= 0) {
      pld = ld * 2;
    } else {
      pld = abs(ld) * 2 - 1;
    }
    ll likes_taken = (m - ost + ld) / 2;
    ll unlikes_taken = (m - ost - ld) / 2;
    ll &ans = cc[ost % 2][like][pld];
    if (ans != -1) {
      return ans;
    }
    ans = 0;
    ll all_count = all_sum + ld;
    if (all_count < 0) {
      return 0;
    }
    ll choose_cur_ver = 1;
    ll cur_inv = invs[all_count - all_sum + MAX_ADD];
    ll unlike_count = all_unlikes - unlikes_taken - (like == 0 ? 1 : 0);
    ans += dp(like, ld - 1, ost - 1) * ((unlike_count * cur_inv) % MOD);
    ll like_count = all_likes + likes_taken - (like == 1 ? 1 : 0);
    ans += dp(like, ld + 1, ost - 1) * ((like_count * cur_inv) % MOD);
    if (like) {
      ans += dp(like, ld + 1, ost - 1) * cur_inv * 2LL;
    }
    ans %= MOD;
    return ans;
  }

 public:
  void solve(int n) {
    this->n = n;
    cin >> m;
    likes.resize(n);
    weights.resize(n);
    for (auto &it : likes) {
      cin >> it;
    }
    for (auto &it : weights) {
      cin >> it;
    }
    all_sum = 0;
    all_likes = 0;
    all_unlikes = 0;
    for (int i = 0; i < n; i++) {
      all_sum += weights[i];
      if (likes[i]) {
        all_likes += weights[i];
      } else {
        all_unlikes += weights[i];
      }
    }
    invs.resize(2 * MAX_ADD + 1);
    for (ll i = -MAX_ADD; i <= MAX_ADD; i++) {
      invs[i + MAX_ADD] = modinv(all_sum + i);
    }
    for (int a = 0; a < 2; a++) {
      for (int b = 0; b < 2; b++) {
        cc[a][b].resize(2 * MAX_ADD + 5, -1);
      }
    }
    for (int ost = 0; ost < m; ost++) {
      for (int b = 0; b < 2; b++) {
        fill(cc[ost % 2][b].begin(), cc[ost % 2][b].end(), -1);
      }
      for (int b = 0; b < 2; b++) {
        for (int ld = 0; ld <= MAX_ADD; ld++) {
          dp(b, ld, ost);
          dp(b, -ld, ost);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int b = 0; b < 2; b++) {
        fill(cc[m % 2][b].begin(), cc[m % 2][b].end(), -1);
      }
      cout << (weights[i] * dp(likes[i], 0, m)) % MOD << endl;
    }
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while (cin >> n) {
    solver s;
    s.solve(n);
  }
}
