#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return x;
}
const int maxn = 2e5 + 10;
const int mod = 998244353;
const double eps = 1e-9;
long long f[51][51], g[51][51];
long long inv[3000];
long long qpow(int a, int b) {
  if (b == 0) return 1;
  long long now = qpow(a, b / 2);
  now = now * now % mod;
  if (b & 1) now = now * a % mod;
  return now;
}
int like[51], cnt[2], w[51];
int main() {
  inv[0] = inv[1] = 1;
  for (int i = 2; i < 3000; ++i) inv[i] = qpow(i, mod - 2);
  int n = read(), m = read();
  for (int i = 1; i <= n; ++i) like[i] = read();
  for (int i = 1; i <= n; ++i) {
    w[i] = read();
    cnt[like[i]] += w[i];
  }
  int sum = cnt[0] + cnt[1];
  for (int j = 0; j <= m; ++j) {
    f[j][m - j] = 1;
    g[j][m - j] = 1;
  }
  for (int j = m - 1; j >= 0; --j) {
    for (int k = m - j - 1; k >= 0; --k) {
      f[j][k] = ((cnt[1] + j + 1) * inv[sum + j - k] % mod * f[j + 1][k] % mod +
                 (cnt[0] - k) * inv[sum + j - k] % mod * f[j][k + 1]) %
                mod;
      g[j][k] = ((cnt[1] + j) * inv[sum + j - k] % mod * g[j + 1][k] % mod +
                 (cnt[0] - k - 1) * inv[sum + j - k] % mod * g[j][k + 1]) %
                mod;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (like[i])
      printf("%lld\n", w[i] * f[0][0] % mod);
    else
      printf("%lld\n", w[i] * g[0][0] % mod);
  }
}
