#include <bits/stdc++.h>
inline long long read() {
  long long x = 0;
  char c = getchar(), f = 1;
  for (; c < '0' || '9' < c; c = getchar())
    if (c == '-') f = -1;
  for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
inline void write(long long x) {
  static int buf[20], len;
  len = 0;
  if (x < 0) x = -x, putchar('-');
  for (; x; x /= 10) buf[len++] = x % 10;
  if (!len)
    putchar('0');
  else
    while (len) putchar(buf[--len] + '0');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
inline void writesp(long long x) {
  write(x);
  putchar(' ');
}
int a[200010], w[200010];
int f[3010][3010], g[3010][3010], inv[2 * 3010];
int n, m;
long long power(long long a, long long b) {
  long long ret = 1;
  for (; b; b >>= 1, a = a * a % 998244353)
    if (b & 1) ret = ret * a % 998244353;
  return ret;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) w[i] = read();
  int SA = 0, SB = 0;
  for (int i = 1; i <= n; i++)
    if (a[i])
      SA += w[i];
    else
      SB += w[i];
  for (int i = 0; i <= 2 * m; i++)
    inv[i] = power(((SA + SB + i - m) % 998244353 + 998244353) % 998244353,
                   998244353 - 2);
  for (int i = m; i >= 0; i--) {
    f[i][m - i] = g[i][m - i] = 1;
    for (int j = m - i - 1; j >= 0; j--) {
      f[i][j] =
          ((long long)f[i + 1][j] * (SA + i + 1) % 998244353 * inv[i - j + m] +
           (long long)f[i][j + 1] * (SB - j + 998244353) % 998244353 *
               inv[i - j + m]) %
          998244353;
      g[i][j] =
          ((long long)g[i + 1][j] * (SA + i) % 998244353 * inv[i - j + m] +
           (long long)g[i][j + 1] * (SB - j - 1 + 998244353) % 998244353 *
               inv[i - j + m]) %
          998244353;
    }
  }
  for (int i = 1; i <= n; i++)
    if (a[i])
      writeln((long long)f[0][0] * w[i] % 998244353);
    else
      writeln((long long)g[0][0] * w[i] % 998244353);
  return 0;
}
