#include <bits/stdc++.h>
using namespace std;
const int maxn = 52 + 5;
const int mod = 998244353;
long long qp(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
template <class T>
inline bool scan(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void out(T x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};
mint operator+(mint a, mint b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mod : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % mod; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }
istream &operator>>(istream &o, mint a) { return o >> a.n; }
int n, m;
mint dp[maxn][maxn][maxn];
int tp[maxn];
mint w[maxn];
mint inv[maxn * maxn];
int main() {
  for (int i = 0; i < maxn * maxn; ++i) inv[i] = qp(i, mod - 2);
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &tp[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &w[i].n);
  }
  int wgood = 0, wbad = 0;
  for (int i = 1; i <= n; ++i) {
    if (tp[i] == 1)
      wgood += w[i].n;
    else
      wbad += w[i].n;
  }
  for (int i = 1; i <= n; ++i) {
    memset(dp, 0, sizeof dp);
    dp[0][0][0] = 1;
    for (int step = 0; step <= m; ++step) {
      for (int j = 0; j <= step; ++j) {
        int k = step - j;
        int up = tp[i] ? j : min(w[i].n, k);
        mint invk = inv[wgood + wbad - k + j];
        for (int hit = 0; hit <= up; ++hit) {
          mint tmp = dp[hit][j][k] * invk;
          if (tp[i]) {
            dp[hit][j + 1][k] += tmp * (wgood + j - (w[i] + hit));
            dp[hit][j][k + 1] += tmp * (wbad - k);
            dp[hit + 1][j + 1][k] += tmp * (w[i] + hit);
          } else {
            dp[hit][j + 1][k] += tmp * (wgood + j);
            dp[hit][j][k + 1] += tmp * (wbad - k - (w[i] - hit));
            dp[hit + 1][j][k + 1] += tmp * (w[i] - hit);
          }
        }
      }
    }
    mint res = 0;
    for (int j = 0; j <= m; ++j) {
      int k = m - j;
      int up = tp[i] ? j : min(w[i].n, k);
      for (int hit = 0; hit <= up; ++hit) {
        if (tp[i])
          res += hit * dp[hit][j][k];
        else
          res -= hit * dp[hit][j][k];
      }
    }
    printf("%d\n", (res + w[i]).n);
  }
  return 0;
}
