#include <bits/stdc++.h>
using namespace std;
int dp[2555][105][55];
long long a[55], wi[55], cur, sp, sn, su, mo;
long long expo(long long base, long long exponent, long long mod = 998244353) {
  long long ans = 1;
  while (exponent != 0) {
    if ((exponent & 1) == 1) {
      ans = ans * base;
      ans = ans % mod;
    }
    base = base * base;
    base %= mod;
    exponent >>= 1;
  }
  return ans % mod;
}
long long add(long long x, long long y, long long mod = 998244353) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
long long sub(long long x, long long y, long long mod = 998244353) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
long long mul(long long x, long long y, long long mod = 998244353) {
  return (x * 1ll * y) % mod;
}
long long solve(long long w, long long s, long long m) {
  if (m == 0) return w;
  if (w == 0) return 0;
  if (dp[w][s][m] != -1) return dp[w][s][m];
  long long ans;
  long long left = (mo - m) - abs(w - wi[cur]);
  long long curs = (s - w) - su;
  long long snu = (left - curs) / 2, spu = (left + curs) / 2;
  if (a[cur]) {
    ans = mul(w, solve(w + 1, s + 1, m - 1));
    if (sn - snu) ans = add(ans, mul(sn - snu, solve(w, s - 1, m - 1)));
    if (sp + spu) ans = add(mul(sp + spu, solve(w, s + 1, m - 1)), ans);
    ans = mul(ans, expo(s, 998244353 - 2));
  } else {
    ans = mul(w, solve(w - 1, s - 1, m - 1));
    if (sn - snu) ans = add(ans, mul(sn - snu, solve(w, s - 1, m - 1)));
    if (sp + spu) ans = add(ans, mul(sp + spu, solve(w, s + 1, m - 1)));
    ans = mul(ans, expo(s, 998244353 - 2));
  }
  dp[w][s][m] = ans;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long n, m;
    cin >> n >> m;
    mo = m;
    long long s = 0;
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < n; i++) {
      cin >> wi[i];
      s += wi[i];
      if (a[i])
        sp += wi[i];
      else
        sn += wi[i];
    }
    su = s;
    for (long long i = 0; i < n; i++) {
      for (long long l = 0; l < s + m + 1; l++)
        for (long long j = 0; j < m + 1 + wi[i]; j++)
          for (long long k = 0; k < m + 1; k++) dp[j][l][k] = -1;
      cur = i;
      if (a[i])
        sp -= wi[i];
      else
        sn -= wi[i];
      su -= wi[i];
      cout << solve(wi[i], s, m) << '\n';
      if (a[i])
        sp += wi[i];
      else
        sn += wi[i];
      su += wi[i];
    }
  }
  return 0;
}
