#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch - '0' < 0 || ch - '0' > 9) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch - '0' >= 0 && ch - '0' <= 9) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m;
int a[55], w[55];
int A, B;
int f[55][55][55];
int inv[3010];
int quick_pow(int x, int p) {
  int an = 1;
  int po = x;
  while (p) {
    if (p & 1) an = 1ll * an * po % 998244353;
    po = 1ll * po * po % 998244353;
    p >>= 1;
  }
  return an;
}
void solve(int id) {
  memset(f, 0, sizeof(f));
  f[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++) {
        if (!f[i][j][k]) continue;
        if (a[id]) {
          int nowA = A + k, nowB = B - (i - k), sum = A + B + k - (i - k),
              noww = w[id] + j;
          f[i + 1][j + 1][k + 1] +=
              1ll * f[i][j][k] * noww % 998244353 * inv[sum] % 998244353;
          f[i + 1][j + 1][k + 1] %= 998244353;
          f[i + 1][j][k + 1] += 1ll * f[i][j][k] * (nowA - noww) % 998244353 *
                                inv[sum] % 998244353;
          f[i + 1][j][k + 1] %= 998244353;
          f[i + 1][j][k] +=
              1ll * f[i][j][k] * nowB % 998244353 * inv[sum] % 998244353;
          f[i + 1][j][k] %= 998244353;
        } else {
          int nowA = A + k, nowB = B - (i - k), sum = A + B + k - (i - k),
              noww = w[id] - j;
          f[i + 1][j + 1][k] +=
              1ll * f[i][j][k] * noww % 998244353 * inv[sum] % 998244353;
          f[i + 1][j + 1][k] %= 998244353;
          f[i + 1][j][k + 1] +=
              1ll * f[i][j][k] * nowA % 998244353 * inv[sum] % 998244353;
          f[i + 1][j][k + 1] %= 998244353;
          f[i + 1][j][k] += 1ll * f[i][j][k] * (nowB - noww) % 998244353 *
                            inv[sum] % 998244353;
          f[i + 1][j][k] %= 998244353;
        }
      }
    }
  }
  int res = 0;
  for (int j = 0; j <= m; j++) {
    for (int k = 0; k <= m; k++) {
      if (!f[m][j][k]) continue;
      if (a[id])
        res = (res + 1ll * (w[id] + j) * f[m][j][k] % 998244353) % 998244353;
      else
        res = (res + 1ll * (w[id] - j) * f[m][j][k] % 998244353) % 998244353;
    }
  }
  printf("%d\n", res);
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= 3000; i++) inv[i] = quick_pow(i, 998244353 - 2);
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) w[i] = read();
  for (int i = 1; i <= n; i++) A += w[i] * (a[i] == 1), B += w[i] * (a[i] == 0);
  for (int i = 1; i <= n; i++) solve(i);
  return 0;
}
