#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b) { a = (a + b) % MOD; }
void mul(int64_t& a, int64_t b) { a = a * b % MOD; }
int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {
  int64_t d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
int64_t inv_mod(int64_t a) {
  int64_t x, y;
  extgcd(a, MOD, x, y);
  return (MOD + x % MOD) % MOD;
}
int main() {
  int N, M, A[50], W[50];
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> W[i];
  int sum[2] = {0};
  for (int i = 0; i < N; i++) sum[A[i]] += W[i];
  for (int x = 0; x < N; x++) {
    int64_t dp[51][51][51] = {0};
    dp[0][0][0] = 1;
    sum[A[x]] -= W[x];
    for (int i = 0; i < M; i++)
      for (int j = 0; j < M; j++)
        for (int k = 0; k < M; k++) {
          if (dp[i][j][k] == 0) continue;
          int l = i - j - k;
          int s0 = sum[0] - k;
          int s1 = sum[1] + l;
          int sx = W[x] + (A[x] ? j : -j);
          int ws = s0 + s1 + sx;
          int iv = inv_mod(ws);
          int64_t C = dp[i][j][k] * iv % MOD;
          add(dp[i + 1][j + 1][k], sx * C % MOD);
          add(dp[i + 1][j][k + 1], s0 * C % MOD);
          add(dp[i + 1][j][k], s1 * C % MOD);
        }
    int64_t ans = 0;
    for (int j = 0; j <= M; j++) {
      int w = W[x] + (A[x] ? j : -j);
      for (int k = 0; k <= M; k++) {
        add(ans, w * dp[M][j][k] % MOD);
      }
    }
    cout << ans << endl;
    sum[A[x]] += W[x];
  }
  return 0;
}
