#include <bits/stdc++.h>
using namespace std;
const long long N = 55;
const long long M = 998244353;
long long n, m, inv[5050];
long long a[N], w[N];
long long like = 0, dislike = 0;
long long dp[N][N][N];
void add(long long &a, long long b) {
  a += b;
  if (a >= M) a -= M;
}
long long qpow(long long a, long long b, long long mod = M) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
void init() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
  }
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &w[i]);
    if (a[i])
      like += w[i];
    else
      dislike += w[i];
  }
  for (long long i = 0; i <= 3000; ++i) inv[i] = qpow(i, M - 2);
}
long long run1(long long x) {
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (long long i = 0; i < m; ++i) {
    for (long long j = 0; j <= i; ++j) {
      for (long long k = 0; k <= j; ++k) {
        if (!dp[i][j][k]) continue;
        add(dp[i + 1][j + 1][k + 1],
            dp[i][j][k] * (k + w[x]) % M * inv[like + j + dislike - i + j] % M);
        add(dp[i + 1][j + 1][k], dp[i][j][k] * (like + j - k - w[x]) % M *
                                     inv[like + j + dislike - i + j] % M);
        add(dp[i + 1][j][k], dp[i][j][k] * (dislike - i + j) % M *
                                 inv[like + j + dislike - i + j] % M);
      }
    }
  }
  long long ans = 0;
  for (long long j = 0; j <= m; ++j) {
    for (long long k = 0; k <= m; ++k) {
      add(ans, dp[m][j][k] * (k + w[x]) % M);
    }
  }
  return ans;
}
long long run2(long long x) {
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (long long i = 0; i < m; ++i) {
    for (long long j = 0; j <= i; ++j) {
      for (long long k = 0; k <= i; ++k) {
        if (!dp[i][j][k]) continue;
        add(dp[i + 1][j][k + 1],
            dp[i][j][k] * (w[x] - k) % M * inv[like + j + dislike - i + j] % M);
        add(dp[i + 1][j + 1][k],
            dp[i][j][k] * (like + j) % M * inv[like + j + dislike - i + j] % M);
        add(dp[i + 1][j][k], dp[i][j][k] * (dislike - i + j - (w[x] - k)) % M *
                                 inv[like + j + dislike - i + j] % M);
      }
    }
  }
  long long ans = 0;
  for (long long j = 0; j <= m; ++j) {
    for (long long k = 0; k <= m; ++k) {
      add(ans, dp[m][j][k] * (w[x] - k) % M);
    }
  }
  return ans;
}
void solve() {
  for (long long i = 1; i <= n; ++i) {
    if (a[i])
      printf("%lld\n", run1(i));
    else
      printf("%lld\n", run2(i));
  }
}
int main() {
  init();
  solve();
  return 0;
}
