#include <bits/stdc++.h>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
using namespace ::std;
const int maxn = 2e5 + 500;
const int mod = 998244353;
inline int zarb(long long a, long long b) { return (a * b) % mod; }
inline int jam(long long a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int poww(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) {
      ans = zarb(ans, a);
    }
    a = zarb(a, a);
    b >>= 1;
  }
  return ans;
}
int po[7000];
int ml[3004][3004];
bool vis[3004][3004];
int SS, l, r, SA, SB;
int findAns(int a, int b, int m) {
  if (m == 0) return 0;
  if (b == 0) return m;
  if (vis[a - SA][SB - b]) {
    return ml[a - SA][SB - b];
  }
  int s = a + b;
  int rs = po[s - l];
  int t1 = findAns(a + 1, b, m - 1);
  int t2 = findAns(a, b - 1, m - 1);
  int f = jam(zarb(zarb(a, rs), 1 + t1), zarb(zarb(b, rs), t2));
  ml[a - SA][SB - b] = f;
  vis[a - SA][SB - b] = 1;
  return f;
}
int a[maxn];
int w[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  int swk = 0;
  int swb = 0;
  for (int i = 0; i < n; i++) {
    if (a[i]) {
      swk += w[i];
    } else {
      swb += w[i];
    }
  }
  SA = swk;
  SB = swb;
  SS = swk + swb;
  l = max(0, SS - 3003);
  r = SS + 3003;
  for (int i = max(0, SS - 3003); i <= SS + 3003; i++) {
    po[i - l] = poww(i, mod - 2);
  }
  int x = findAns(swk, swb, m);
  pair<int, int> r = make_pair(x, (m - x + mod) % mod);
  int rswk = poww(swk, mod - 2);
  int rswb = poww(swb, mod - 2);
  for (int i = 0; i < n; i++) {
    if (a[i]) {
      int o = zarb(r.first, zarb(w[i], rswk));
      cout << jam(w[i], o) << endl;
    } else {
      int o = zarb(r.second, zarb(w[i], rswb));
      cout << (w[i] - o + mod) % mod << endl;
      ;
    }
  }
}
