#include <bits/stdc++.h>
using namespace std;
const int max_n = 200005;
const int max_m = 3005;
const int mod = 998244353;
namespace {
inline int Add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
inline int Sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; }
inline int Mul(int x, int y) { return 1ll * x * y % mod; }
inline int Pow(int x, int y = mod - 2) {
  int res = 1;
  while (y) {
    if (y & 1) res = 1ll * res * x % mod;
    x = 1ll * x * x % mod;
    y >>= 1;
  }
  return res;
}
}  // namespace
int n, m;
int a[max_n], w[max_n];
int dp[max_m][max_m];
int _inv[max_m * 2], *inv;
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", w + i);
  int sa = 0, sb = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1)
      sa += w[i];
    else
      sb += w[i];
  }
  int s = sa + sb;
  inv = _inv - (s - m);
  for (int i = s - m; i <= s + m; i++) inv[i] = Pow(i, mod - 2);
  dp[0][0] = 1;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j <= i; j++) {
      int ta = sa + j, tb = sb - (i - j);
      int y = Mul(inv[ta + tb], dp[i][j]);
      dp[i + 1][j + 1] = Add(dp[i + 1][j + 1], Mul(y, ta));
      dp[i + 1][j] = Add(dp[i + 1][j], Mul(y, tb));
    }
  }
  int ea = 0, eb = 0;
  for (int i = 0; i <= m; i++) {
    ea = Add(ea, Mul(sa + i, dp[m][i]));
    eb = Add(eb, Mul(sb - (m - i), dp[m][i]));
  }
  int inva = Pow(sa, mod - 2), invb = Pow(sb, mod - 2);
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1)
      printf("%d\n", 1ll * ea * w[i] % mod * inva % mod);
    else
      printf("%d\n", 1ll * eb * w[i] % mod * invb % mod);
  }
  return 0;
}
