#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, y = 0, c = getchar();
  while (!isdigit(c)) y = c, c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
  return y == '-' ? -x : x;
}
inline void print(long long q) {
  if (q < 0) putchar('-'), q = -q;
  if (q >= 10) print(q / 10);
  putchar(q % 10 + '0');
}
long long s1 = 19260817, s2 = 23333333, s3 = 998244353, srd;
inline long long rd() { return srd = (srd * s1 + s2 + rand()) % s3; }
void file() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
int n, m, a[200010];
bool b[200010];
const int mo = 998244353;
inline long long ksm(long long q, long long w) {
  q %= mo;
  long long as = 1;
  while (w) {
    if (w & 1) as = as * q % mo;
    q = q * q % mo;
    w >>= 1;
  }
  return as;
}
long long f[3010][3010], g[6010], p1, p0, tot;
int main() {
  srand(time(0));
  rd();
  int i, j;
  n = read();
  m = read();
  for (i = 1; i <= n; ++i) b[i] = read();
  for (i = 1; i <= n; ++i) {
    a[i] = read();
    tot += a[i];
    (b[i] ? p1 : p0) += a[i];
  }
  for (i = 0; i <= m + m; ++i) g[i] = ksm(tot + i - m + mo, mo - 2);
  f[0][0] = 1;
  for (i = 0; i < m; ++i)
    for (j = 0; j <= i; ++j) {
      int tp = i - j;
      (f[i + 1][j + 1] += f[i][j] * (p1 + j) % mo * g[j - tp + m]) %= mo;
      (f[i + 1][j] += f[i][j] * (p0 - tp + mo) % mo * g[j - tp + m]) %= mo;
    }
  long long g1 = 0, g0 = 0;
  for (i = 0; i <= m; ++i)
    (g1 += f[m][i] * (p1 + i)) %= mo,
        (g0 += f[m][i] * (p0 - (m - i) + mo)) %= mo;
  (g1 *= ksm(p1, mo - 2)) %= mo;
  (g0 *= ksm(p0, mo - 2)) %= mo;
  for (i = 1; i <= n; ++i) {
    if (b[i])
      print(g1 * a[i] % mo);
    else
      print(g0 * a[i] % mo);
    putchar('\n');
  }
  return 0;
}
