#include <bits/stdc++.h>
using namespace std;
const int N = 51;
const int mod = 998244353;
template <typename T>
inline void init(T& x) {
  x = 0;
  char ch = getchar();
  bool t = 0;
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') t = 1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + (ch - 48);
  if (t) x = -x;
  return;
}
template <typename T>
inline void Inc(T& x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return;
}
template <typename T>
inline void Dec(T& x, int y) {
  x -= y;
  if (x < 0) x += mod;
  return;
}
template <typename T>
inline int fpow(int x, T k) {
  int ret = 1;
  for (; k; k >>= 1, x = (long long)x * x % mod)
    if (k & 1) ret = (long long)ret * x % mod;
  return ret;
}
inline int Sum(int x, int y) {
  x += y;
  if (x >= mod) return x - mod;
  return x;
}
inline int Dif(int x, int y) {
  x -= y;
  if (x < 0) return x + mod;
  return x;
}
const int MAX = 10000;
int m;
int dp[N][N][N];
int n;
int a[N];
int w[N];
int Inv[MAX];
inline int Solve(int id) {
  int lsum = 0, rsum = 0, S = 0;
  for (int i = 1; i <= n; ++i) {
    S += w[i];
    if (i == id) continue;
    if (a[i])
      lsum += w[i];
    else
      rsum += w[i];
  }
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (int i = 1; i <= m; ++i) {
    for (int j = 0; j < i; ++j) {
      if (!a[id] && j > w[id]) continue;
      for (int k = 0; k + j < i; ++k) {
        if (!dp[i - 1][j][k]) continue;
        if (a[id]) {
          int s = lsum + k;
          int d = i - 1 - j - k;
          int nS = S + j + k - d;
          if (rsum < d) continue;
          Inc(dp[i][j + 1][k],
              (long long)dp[i - 1][j][k] * (w[id] + j) % mod * Inv[nS] % mod);
          Inc(dp[i][j][k + 1],
              (long long)dp[i - 1][j][k] * s % mod * Inv[nS] % mod);
          Inc(dp[i][j][k],
              (long long)dp[i - 1][j][k] * (rsum - d) % mod * Inv[nS] % mod);
        } else {
          int s = lsum + k;
          int d = i - 1 - j - k;
          int nS = S + k - j - d;
          if (rsum < d) continue;
          Inc(dp[i][j + 1][k],
              (long long)dp[i - 1][j][k] * (w[id] - j) % mod * Inv[nS] % mod);
          Inc(dp[i][j][k + 1],
              (long long)dp[i - 1][j][k] * s % mod * Inv[nS] % mod);
          Inc(dp[i][j][k],
              (long long)dp[i - 1][j][k] * (rsum - d) % mod * Inv[nS] % mod);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= m; ++i) {
    int s = 0;
    int data = w[id];
    if (a[id] == 1)
      data += i;
    else
      data -= i;
    if (data < 0) break;
    for (int j = 0; j <= m; ++j) Inc(s, dp[m][i][j]);
    Inc(ans, (long long)data * s % mod);
  }
  return ans;
}
int main() {
  init(n), init(m);
  for (int i = 1; i <= n; ++i) init(a[i]);
  for (int i = 1; i <= n; ++i) init(w[i]);
  Inv[1] = 1;
  for (int i = 2; i < 10000; ++i)
    Inv[i] = (long long)(mod - mod / i) * Inv[mod % i] % mod;
  for (int i = 1; i <= n; ++i) printf("%d\n", Solve(i));
  return 0;
}
