#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long binpow(long long x, long long p) {
  if (p == 0) return 1;
  if (p & 1) return x * binpow(x, p - 1) % mod;
  return binpow(x * x % mod, p >> 1);
}
long long inv(long long x) { return binpow(x, mod - 2); }
const long long maxn = 55;
long long dp[maxn][maxn][maxn];
long long solve(long long m, long long sum, long long sumliked, long long w,
                long long is_liked) {
  long long direction = (is_liked) ? 1 : -1;
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (long long steps = 0; steps < m; ++steps) {
    for (long long cnt_liked = 0; cnt_liked <= steps; ++cnt_liked) {
      for (long long cnt_me = 0; cnt_me <= steps; ++cnt_me) {
        long long cursum = sum + cnt_liked - (steps - cnt_liked);
        long long curliked = sumliked + cnt_liked;
        long long cur_unliked = cursum - curliked;
        long long curw = w + direction * cnt_me;
        if (cursum < curliked || curw < 0) continue;
        if (!dp[steps][cnt_liked][cnt_me]) continue;
        if (is_liked) {
          curliked -= curw;
        } else {
          cur_unliked -= curw;
        }
        {
          dp[steps + 1][cnt_liked + is_liked][cnt_me + 1] +=
              dp[steps][cnt_liked][cnt_me] * curw % mod * inv(cursum);
          dp[steps + 1][cnt_liked + is_liked][cnt_me + 1] %= mod;
        }
        {
          dp[steps + 1][cnt_liked + 1][cnt_me] +=
              dp[steps][cnt_liked][cnt_me] * curliked % mod * inv(cursum);
          dp[steps + 1][cnt_liked + 1][cnt_me] %= mod;
        }
        {
          dp[steps + 1][cnt_liked][cnt_me] +=
              dp[steps][cnt_liked][cnt_me] * cur_unliked % mod * inv(cursum);
          dp[steps + 1][cnt_liked][cnt_me] %= mod;
        }
      }
    }
  }
  long long ans = 0;
  for (long long cnt_liked = 0; cnt_liked <= m; ++cnt_liked) {
    for (long long cnt_me = 0; cnt_me <= m; ++cnt_me) {
      ans += dp[m][cnt_liked][cnt_me] * (w + direction * cnt_me);
      ans %= mod;
    }
  }
  if (ans < 0) ans += mod;
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long> w(n);
  long long sum = 0;
  long long sumliked = 0;
  for (long long i = 0; i < n; ++i) {
    cin >> w[i];
    if (a[i]) {
      sumliked += w[i];
    }
    sum += w[i];
  }
  for (long long i = 0; i < n; ++i) {
    cout << solve(m, sum, sumliked, w[i], a[i]) << '\n';
  }
}
