#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
using ll = long long;
const ll mod = 998244353;
const int maxn = 1e4;
const int N = 57;
ll pw(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y % 2) res = res * x % mod;
    x = x * x % mod;
    y = y / 2;
  }
  return ((res % mod) + mod) % mod;
}
ll inverse(ll x) {
  assert(x > 0);
  return pw(x, mod - 2);
}
ll fac[maxn], ifac[maxn], inv[maxn];
ll nck(ll n, ll k) {
  if (n < k) return 0;
  return fac[n] * ifac[k] % mod * ifac[n - k] % mod;
}
void gen_inv() {
  fac[0] = inv[0] = ifac[0] = 1;
  fac[1] = inv[1] = ifac[1] = 1;
  for (int i = 2; i < maxn; i++) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
    ifac[i] = ifac[i - 1] * inv[i] % mod;
  }
  assert(nck(4, 2) == 6);
}
int n, m;
ll a[N];
ll w[N];
ll wt[2];
ll dp[N][N][N];
ll nxtwei(int i, ll dx) {
  if (a[i] == 0) return w[i] - dx;
  return w[i] + dx;
}
void add(ll &x, ll y) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  x += y;
  if (x >= mod) x %= mod;
}
ll solve(int x) {
  wt[a[x]] -= w[x];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j <= i; j++) {
      for (int k = 0; j + k <= i; k++) {
        if (wt[0] - j < 0) continue;
        if (nxtwei(x, i - j - k) < 0) continue;
        ll den = inv[(wt[0] - j) + (wt[1] + k) + nxtwei(x, i - j - k)];
        add(dp[i + 1][j][k],
            dp[i][j][k] * nxtwei(x, i - j - k) % mod * den % mod);
        add(dp[i + 1][j][k + 1], dp[i][j][k] * (wt[1] + k) % mod * den % mod);
        add(dp[i + 1][j + 1][k], dp[i][j][k] * (wt[0] - j) % mod * den % mod);
      }
    }
  }
  ll res = 0;
  for (int j = 0; j <= m; j++) {
    for (int k = 0; k + j <= m; k++) {
      ll cur = dp[m][j][k] * nxtwei(x, m - j - k) % mod;
      add(res, cur);
    }
  }
  wt[a[x]] += w[x];
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  gen_inv();
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    wt[a[i]] += w[i];
  }
  for (int i = 0; i < n; i++) {
    cout << solve(i) << "\n";
  }
  return 0;
}
