#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 9;
const int maxm = 3e3 + 9;
const long long mod = 998244353;
int add[maxn];
long long w[maxn];
long long dp[maxm][maxm];
long long val[maxm][maxm];
bool vis[maxm][maxm];
long long Pow(long long a, long long b) {
  long long res = 1;
  a %= mod;
  while (b) {
    if (b & 1) res = res * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return res;
}
inline long long inv(long long a) { return Pow(a, mod - 2); }
long long INV[2 * maxm];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  long long s0 = 0, s1 = 0, inv0, inv1;
  for (int i = 1; i <= n; i++) scanf("%d", add + i);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", w + i);
    if (add[i])
      s1 += w[i];
    else
      s0 += w[i];
  }
  inv0 = inv(s0);
  inv1 = inv(s1);
  for (int i = -m - 1; i <= m + 1; i++) {
    if (s0 + s1 + i <= 0) continue;
    INV[i + maxm] = inv(s0 + s1 + i);
  }
  dp[0][0] = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= i; j++) {
      dp[j][i - j] = (j == 0) ? 0
                              : (dp[j - 1][i - j] * (s1 + j - 1) % mod *
                                 INV[j - 1 - (i - j) + maxm] % mod);
      dp[j][i - j] += (i - j == 0) ? 0
                                   : (dp[j][i - j - 1] * (s0 - (i - j - 1)) %
                                      mod * INV[j - (i - j - 1) + maxm] % mod);
      dp[j][i - j] %= mod;
    }
  }
  long long ans[2] = {0, 0};
  for (int i = 0; i <= m; i++) {
    ans[1] += dp[i][m - i] * (s1 + i) % mod;
    ans[0] += dp[i][m - i] * (s0 - m + i) % mod;
  }
  ans[0] %= mod, ans[1] %= mod;
  for (int i = 1; i <= n; i++) {
    if (add[i]) {
      printf("%d\n", w[i] * ans[1] % mod * inv1 % mod);
    } else {
      printf("%d\n", w[i] * ans[0] % mod * inv0 % mod);
    }
  }
}
