#include <bits/stdc++.h>
using namespace std;
char gc() { return getchar(); }
template <class T>
int read(T &ans) {
  T f = 1;
  ans = 0;
  char ch = gc();
  while (!isdigit(ch)) {
    if (ch == EOF) return EOF;
    if (ch == '-') f = -1;
    ch = gc();
  }
  while (isdigit(ch)) ans = ans * 10 + ch - '0', ch = gc();
  ans *= f;
  return 1;
}
template <class T1, class T2>
int read(T1 &a, T2 &b) {
  return read(a) == EOF ? EOF : read(b);
}
template <class T1, class T2, class T3>
int read(T1 &a, T2 &b, T3 &c) {
  return read(a, b) == EOF ? EOF : read(c);
}
const long long Maxn = 1100000;
const long long inf = 0x3f3f3f3f;
const long long mod = 998244353;
long long n, m, a[Maxn], b[Maxn], sxz, zhy, f[3100][3100], ansx, ansy;
long long powp(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
signed main() {
  read(n, m);
  for (long long i = 1; i <= n; i++) read(a[i]);
  for (long long i = 1; i <= n; i++) read(b[i]);
  for (long long i = 1; i <= n; i++)
    if (a[i])
      sxz = (sxz + b[i]) % mod;
    else
      zhy = (zhy + b[i]) % mod;
  f[0][0] = 1;
  for (long long i = 1; i <= m; i++)
    for (long long j = 0; j < i; j++) {
      if (i - j - 1 == zhy)
        f[j + 1][i - j - 1] = (f[j + 1][i - j - 1] + f[j][i - j - 1]) % mod;
      else {
        long long x = sxz + j, y = zhy - (i - j - 1),
                  tot = powp(x + y, mod - 2);
        f[j + 1][i - j - 1] = (f[j + 1][i - j - 1] +
                               1ll * f[j][i - j - 1] * x % mod * tot % mod) %
                              mod;
        f[j][i - j] =
            (f[j][i - j] + 1ll * f[j][i - j - 1] * y % mod * tot % mod) % mod;
      }
    }
  for (long long i = 0; i <= m; i++)
    ansx = (ansx + 1ll * f[i][m - i] * i % mod) % mod,
    ansy = (ansy + 1ll * f[i][m - i] * (m - i) % mod) % mod;
  long long x = (sxz + ansx) % mod, y = (zhy - ansy + mod) % mod;
  sxz = powp(sxz, mod - 2), zhy = powp(zhy, mod - 2);
  for (long long i = 1; i <= n; i++)
    if (a[i])
      printf("%I64d\n", sxz * b[i] % mod * x % mod);
    else
      printf("%I64d\n", zhy * b[i] % mod * y % mod);
  return 0;
}
