#include <bits/stdc++.h>
const int MOD = 998244353;
const int kN = 50 + 5;
int n, m;
int a[kN], w[kN];
int dp[kN][kN][kN];
const int kM = kN * kN * 20;
int Inv[kM];
int inv(int x) {
  return x == 1 ? 1 : (MOD - MOD / x) * 1LL * inv(MOD % x) % MOD;
}
inline void add(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
int main() {
  scanf("%d%d", &n, &m);
  Inv[1] = 1;
  for (int i = 2; i < kM; ++i) Inv[i] = inv(i);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i < n; ++i) scanf("%d", w + i);
  int negative = 0;
  int sum = 0;
  for (int i = 0; i < n; ++i)
    if (a[i] == 0) negative += w[i];
  for (int i = 0; i < n; ++i) sum += w[i];
  for (int i = 0; i < n; ++i) {
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    for (int j = 0; j < m; ++j) {
      for (int k = 0; k <= j; ++k) {
        for (int r = 0; r <= j; ++r)
          if (dp[j][k][r]) {
            int c = a[i] == 1 ? w[i] + k : w[i] - k;
            if (c) {
              add(dp[j + 1][k + 1][r + (a[i] == 0)],
                  dp[j][k][r] * 1LL * c % MOD * Inv[sum - r + j - r] % MOD);
            }
            int ne_ci = negative - (a[i] == 0 ? w[i] : 0);
            int sum_ci = sum - w[i];
            int r_ci = r - (a[i] == 0 ? k : 0);
            int f_ci = j - r - (a[i] == 1 ? k : 0);
            if (ne_ci < sum_ci) {
              add(dp[j + 1][k][r], dp[j][k][r] * 1LL * (sum_ci - ne_ci + f_ci) %
                                       MOD * Inv[sum - r + j - r] % MOD);
            }
            if (ne_ci > r_ci) {
              add(dp[j + 1][k][r + 1], dp[j][k][r] * 1LL * (ne_ci - r_ci) %
                                           MOD * Inv[sum - r + j - r] % MOD);
            }
          }
      }
    }
    int result = w[i];
    for (int k = 0; k <= m; ++k)
      for (int r = 0; r <= m; ++r)
        if (dp[m][k][r])
          add(result, dp[m][k][r] * 1LL * (a[i] == 1 ? k : (MOD - k)) % MOD);
    printf("%d\n", result);
  }
}
