#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 998244353;
int a[maxn], b[maxn], n, m;
long long sum1, sum2, res1, res2, inv1, inv2;
long long dp[3030][3030];
unordered_map<long long, int> Inv;
inline long long qm(long long a, long long b, long long res = 1) {
  for (a %= mod; b; b >>= 1, a = a * a % mod)
    if (b & 1) res = res * a % mod;
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (a[i] == 1)
      sum1 += b[i];
    else
      sum2 += b[i];
  }
  dp[1][1] = sum1 * qm(sum1 + sum2, mod - 2) % mod;
  dp[1][0] = sum2 * qm(sum1 + sum2, mod - 2) % mod;
  for (long long i = max(0LL, sum1 + sum2 - 3030); i <= sum1 + sum2 + 3030;
       i++) {
    Inv[i] = qm(i, mod - 2);
  }
  for (int i = 1; i < m; i++) {
    for (int j = 0; j <= i; j++) {
      int tmp = i - j;
      dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * (sum1 + j) % mod *
                                                 Inv[sum1 + sum2 + j - tmp]) %
                         mod;
      dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * max(0LL, sum2 - tmp) % mod *
                                         Inv[sum1 + sum2 + j - tmp]) %
                     mod;
    }
  }
  for (int i = 0; i <= m; i++) {
    res1 = (res1 + dp[m][i] * (sum1 + i) % mod) % mod;
    res2 = (res2 + dp[m][i] * max(0LL, sum2 - m + i) % mod) % mod;
  }
  inv1 = qm(sum1, mod - 2);
  inv2 = qm(sum2, mod - 2);
  for (int i = 1; i <= n; i++) {
    if (a[i]) {
      printf("%I64d\n", res1 * b[i] % mod * inv1 % mod);
    } else {
      printf("%I64d\n", res2 * b[i] % mod * inv2 % mod);
    }
  }
}
