#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int mul(int a, int b) { return (long long)a * b % mod; }
int add(int a, int b) {
  int res = (long long)a + b;
  if (res < 0)
    res += mod;
  else if (res > mod)
    res -= mod;
  return res;
}
int bpow(int x, int p) {
  int res = 1;
  while (p) {
    if (p & 1) res = mul(res, x);
    p >>= 1;
    if (p) x = mul(x, x);
  }
  return res;
}
int inv(int x) { return bpow(x, mod - 2); }
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> w(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  int sum_pos = 0, sum_neg = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1)
      sum_pos += w[i];
    else
      sum_neg += w[i];
  }
  vector<vector<int>> dp(m + 1, vector<int>(m + 1));
  dp[0][0] = 1;
  vector<int> iv(2 * m + 1);
  for (int i = 0; i <= 2 * m; i++) {
    iv[i] = inv(sum_pos + sum_neg - m + i);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (dp[i][j] == 0) continue;
      int p = mul(sum_pos + j, iv[m + j - (i - j)]);
      dp[i + 1][j + 1] = add(dp[i + 1][j + 1], mul(dp[i][j], p));
      p = mul(sum_neg - (i - j), iv[m + j - (i - j)]);
      dp[i + 1][j] = add(dp[i + 1][j], mul(dp[i][j], p));
    }
  }
  vector<int> ans(n);
  int iv1 = inv(sum_pos);
  int iv2 = inv(sum_neg);
  vector<int> f(2);
  for (int i = 0; i < m + 1; i++) {
    int t = add(1, mul(i, iv1));
    f[0] = add(f[0], mul(dp[m][i], t));
    t = add(1, mul(-(m - i), iv2));
    f[1] = add(f[1], mul(dp[m][i], t));
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      ans[i] = add(ans[i], mul(w[i], f[0]));
    } else {
      ans[i] = add(ans[i], mul(w[i], f[1]));
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q = 1;
  for (; q > 0; q--) {
    solve();
  }
}
