#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const long long mod = 998244353LL;
long long qpow(long long a, long long n) {
  long long ret = 1;
  while (n > 0) {
    if (n & 1) {
      ret = ret * a % mod;
    }
    a = a * a % mod;
    n >>= 1;
  }
  return ret;
}
long long extgcd(long long a, long long b, long long &x, long long &y) {
  long long d = a;
  if (b != 0)
    d = extgcd(b, a % b, y, x), y -= (a / b) * x;
  else
    x = 1, y = 0;
  return d;
}
long long inv(long long a) {
  long long x, y;
  extgcd(a, mod, x, y);
  return (mod + x % mod) % mod;
}
int a[maxn];
long long w[maxn];
int n, m;
int main() {
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    long long w0 = 0, w1 = 0;
    for (int i = 0; i < n; i++) {
      scanf("%lld", &w[i]);
      if (a[i] == 0)
        w0 += w[i];
      else
        w1 += w[i];
    }
    vector<vector<long long>> dp(m + 1, vector<long long>(m + 1));
    dp[0][0] = 1;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < m; j++) {
        if (dp[i][j] && i + j < m) {
          long long w00 = w0 - j, w11 = w1 + i;
          if (w00 < 0 || w00 + w11 <= 0) continue;
          dp[i + 1][j] += ((dp[i][j] * w11 % mod * inv(w00 + w11)));
          dp[i + 1][j] %= mod;
          dp[i][j + 1] += ((dp[i][j] * w00 % mod * inv(w00 + w11)));
          dp[i][j + 1] %= mod;
        }
      }
    }
    long long exp_w0 = 0, exp_w1 = 0;
    long long inv_w0 = inv(w0), inv_w1 = inv(w1);
    for (int i = 0; i <= m; i++) {
      exp_w0 += (dp[m - i][i] * i);
      exp_w0 %= mod;
      exp_w1 += (dp[i][m - i] * i);
      exp_w1 %= mod;
    }
    long long T_T1 = exp_w1 * inv_w1 % mod, T_T0 = exp_w0 * inv_w0 % mod;
    for (int i = 0; i < n; i++) {
      long long tmp;
      if (a[i] == 0) {
        tmp = (-T_T0 * w[i] % mod + w[i] + mod) % mod;
      } else {
        tmp = (T_T1 * w[i] % mod + w[i]) % mod;
      }
      printf("%lld\n", tmp);
    }
  }
  return 0;
}
