#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &res) {
  res = 0;
  T f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
  }
  res *= f;
}
template <class T>
void out(T x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x >= 10) {
    out(x / 10);
  }
  putchar('0' + x % 10);
}
const int MOD = 998244353;
int N, M;
int all, p, b, a[55], w[55];
int dp[55][55], f[55][55];
int inc(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
int mul(int a, int b) { return 1LL * a * b % MOD; }
void update(int &x, int y) { x = inc(x, y); }
int fpow(int x, int c) {
  int res = 1, t = x;
  while (c) {
    if (c & 1) res = mul(res, t);
    t = mul(t, t);
    c >>= 1;
  }
  return res;
}
void Solve() {
  read(N);
  read(M);
  for (int i = 1; i <= N; ++i) {
    read(a[i]);
  }
  for (int i = 1; i <= N; ++i) {
    read(w[i]);
    all += w[i];
    if (a[i])
      p += w[i];
    else
      b += w[i];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= M; ++i) {
    for (int j = 0; j < i; ++j) {
      int nw = all + j - (i - 1 - j);
      int t = mul(p + j, fpow(nw, MOD - 2));
      update(dp[i][j + 1], mul(t, dp[i - 1][j]));
      if (b > (i - 1 - j)) {
        t = mul(b - (i - 1 - j), fpow(nw, MOD - 2));
        update(dp[i][j], mul(t, dp[i - 1][j]));
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    if (a[i]) {
      int ans = 0;
      for (int j = 0; j <= M; ++j) {
        memset(f, 0, sizeof(f));
        f[0][0] = 1;
        for (int k = 1; k <= j; ++k) {
          int nw = p + k - 1;
          for (int h = 0; h < k; ++h) {
            int t = mul(w[i] + h, fpow(nw, MOD - 2));
            update(f[k][h + 1], mul(t, f[k - 1][h]));
            t = (1 + MOD - t) % MOD;
            update(f[k][h], mul(t, f[k - 1][h]));
          }
        }
        for (int h = 0; h <= j; ++h) {
          int t = mul(dp[M][j], f[j][h]);
          update(ans, mul(t, h));
        }
      }
      update(ans, w[i]);
      out(ans);
      putchar('\n');
    } else {
      int ans = 0;
      for (int j = 0; j <= M; ++j) {
        if (!dp[M][M - j]) continue;
        if (j == b) {
          update(ans, mul(dp[M][M - j], w[i]));
          continue;
        }
        memset(f, 0, sizeof(f));
        f[0][0] = 1;
        for (int k = 1; k <= j; ++k) {
          int nw = b - k + 1;
          for (int h = 0; h < k; ++h) {
            int t;
            if (w[i] > h)
              t = mul(w[i] - h, fpow(nw, MOD - 2));
            else
              t = 0;
            update(f[k][h + 1], mul(t, f[k - 1][h]));
            t = inc(1, MOD - t);
            update(f[k][h], mul(t, f[k - 1][h]));
          }
        }
        for (int h = 0; h <= j; ++h) {
          int t = mul(dp[M][M - j], f[j][h]);
          update(ans, mul(t, h));
        }
      }
      ans = inc(w[i], MOD - ans);
      out(ans);
      putchar('\n');
    }
  }
}
int main() {
  Solve();
  return 0;
}
