#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const long long llINF = 2e18;
const double pi = acos(-1);
int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
long long readll() {
  long long v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
int dp1[51][3333][101], dp2[51][3333][101], a[55], w[55], c[10], ans[55], s;
int num[55][111], n, m;
map<pair<int, int>, int> mp;
void predo() {}
int pw(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % MOD;
    x = 1ll * x * x % MOD;
    y >>= 1;
  }
  return res;
}
int inv(long long x) { return pw(x, MOD - 2); }
void init() {
  n = read(), m = read();
  for (int i = (int)1; i <= (int)n; i++) a[i] = read();
  for (int i = (int)1; i <= (int)n; i++) w[i] = read();
}
int dfs1(int i, int s0, int s1, int j) {
  int id = mp[make_pair(s0, s1)];
  if (dp1[i][id][j] != -1) return dp1[i][id][j];
  if (i == m) return 0;
  int s = s0 + s1;
  int invs = inv(s);
  int res = 1ll * j * invs % MOD * (dfs1(i + 1, s0, s1 + 1, j + 1) + 1) % MOD;
  int tot = 0;
  if (s0) tot = (tot + 1ll * s0 * dfs1(i + 1, s0 - 1, s1, j) % MOD) % MOD;
  if (s1 - j)
    tot = (tot + 1ll * (s1 - j) * dfs1(i + 1, s0, s1 + 1, j) % MOD) % MOD;
  tot = 1ll * tot * invs % MOD;
  res = (res + tot) % MOD;
  dp1[i][id][j] = res;
  return res;
}
int dfs2(int i, int s0, int s1, int j) {
  int id = mp[make_pair(s0, s1)];
  if (dp2[i][id][j] != -1) return dp2[i][id][j];
  if (i == m) return 0;
  int s = s0 + s1;
  int invs = inv(s);
  int res = 0;
  if (j)
    res = 1ll * j * invs % MOD * (dfs2(i + 1, s0 - 1, s1, j - 1) + 1) % MOD;
  int tot = 0;
  if (s0 - j)
    tot = (tot + 1ll * (s0 - j) * dfs2(i + 1, s0 - 1, s1, j) % MOD) % MOD;
  if (s1) tot = (tot + 1ll * s1 * dfs2(i + 1, s0, s1 + 1, j) % MOD) % MOD;
  tot = 1ll * tot * invs % MOD;
  res = (res + tot) % MOD;
  dp2[i][id][j] = res;
  return res;
}
void solve() {
  int s0 = 0, s1 = 0;
  for (int i = (int)1; i <= (int)n; i++) {
    if (a[i] == 0)
      s0 += w[i];
    else
      s1 += w[i];
  }
  int cnt = 0;
  for (int i = (int)s0 - m; i <= (int)s0; i++) {
    if (i < 0) continue;
    for (int j = (int)s1; j <= (int)s1 + m; j++) mp[make_pair(i, j)] = ++cnt;
  }
  memset(dp1, -1, sizeof(dp1));
  memset(dp2, -1, sizeof(dp2));
  for (int i = (int)1; i <= (int)n; i++) {
    if (a[i] == 1)
      ans[i] = (w[i] + dfs1(0, s0, s1, w[i])) % MOD;
    else
      ans[i] = (w[i] - dfs2(0, s0, s1, w[i]) + MOD) % MOD;
  }
  for (int i = (int)1; i <= (int)n; i++) printf("%d\n", ans[i]);
}
int main() {
  predo();
  int cas = 1;
  while (cas--) {
    init();
    solve();
  }
  return 0;
}
