#include <bits/stdc++.h>
const int N = 55;
const int P = 998244353;
int n, m, a[N], w[N], inv[N * N], f[N][N][N][N];
void add(int &x, int y) { (x += y) >= P && (x -= P); }
void init(int n) {
  inv[1] = 1;
  for (int i = 2; i <= n; i++) {
    inv[i] = 1LL * (P - P / i) * inv[P % i] % P;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] = (a[i] << 1) - 1;
  }
  int sumA = 0, sumB = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &w[i]);
    (a[i] > 0 ? sumA : sumB) += w[i];
  }
  init(sumA + sumB + m);
  for (int t = 1; t <= n; t++) {
    memset(f, 0, sizeof(f));
    f[0][0][0][0] = 1;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j <= i; j++) {
        for (int k = 0; k <= i; k++) {
          for (int d = 0; d <= (a[t] > 0 ? j : k); d++) {
            if (!f[i][j][k][d]) continue;
            int x = 1LL * f[i][j][k][d] * inv[sumA + sumB + j - k] % P;
            if (a[t] > 0) {
              add(f[i + 1][j + 1][k][d + 1], 1LL * (w[t] + d) * x % P);
              add(f[i + 1][j + 1][k][d], 1LL * (sumA + j - w[t] - d) * x % P);
              add(f[i + 1][j][k + 1][d], 1LL * (sumB - k) * x % P);
            } else {
              add(f[i + 1][j][k + 1][d + 1], 1LL * (w[t] - d) * x % P);
              add(f[i + 1][j][k + 1][d], 1LL * (sumB - k - w[t] + d) * x % P);
              add(f[i + 1][j + 1][k][d], 1LL * (sumA + j) * x % P);
            }
          }
        }
      }
    }
    int ans = 0;
    for (int j = 0; j <= m; j++) {
      for (int k = 0; k <= m; k++) {
        for (int d = 0; d <= (a[t] > 0 ? j : k); d++) {
          add(ans, 1LL * f[m][j][k][d] * (w[t] + a[t] * d) % P);
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
