#include <bits/stdc++.h>
using namespace std;
long long qp(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % 998244353;
    b >>= 1;
    a = (a * a) % 998244353;
  }
  return ans;
}
inline long long add(long long a, long long b) {
  long long c = a + b;
  if (c >= 998244353) c -= 998244353;
  return c;
}
inline long long mul(long long a, long long b) {
  long long c = a * b % 998244353;
  return c;
}
inline long long inv(long long a, long long b) {
  long long c = a * qp(b, 998244353 - 2) % 998244353;
  return c;
}
map<pair<pair<long long, long long>, pair<long long, long long> >, long long>
    dp;
long long n, m, s0, s1, a[55], b[55];
long long dfs(long long i, long long j, long long k, long long l,
              long long id) {
  if (i == m) return j;
  auto x = make_pair(make_pair(i, j), make_pair(k, l));
  if (dp.find(x) != dp.end()) return dp[x];
  dp[x] = 0;
  if (a[id]) {
    dp[x] = add(dp[x], mul(inv(j, k + l), dfs(i + 1, j + 1, k + 1, l, id)));
    if (k - j)
      dp[x] = add(dp[x], mul(inv(k - j, k + l), dfs(i + 1, j, k + 1, l, id)));
    if (l) dp[x] = add(dp[x], mul(inv(l, k + l), dfs(i + 1, j, k, l - 1, id)));
  } else {
    if (j)
      dp[x] = add(dp[x], mul(inv(j, k + l), dfs(i + 1, j - 1, k, l - 1, id)));
    dp[x] = add(dp[x], mul(inv(k, k + l), dfs(i + 1, j, k + 1, l, id)));
    if (l - j)
      dp[x] = add(dp[x], mul(inv(l - j, k + l), dfs(i + 1, j, k, l - 1, id)));
  }
  return dp[x];
}
signed main() {
  scanf("%d%d", &n, &m);
  for (long long i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (long long i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (!a[i])
      s0 += b[i];
    else
      s1 += b[i];
  }
  for (long long i = 1; i <= n; i++) {
    dp.clear();
    printf("%d\n", dfs(0, b[i], s1, s0, i));
  }
  return 0;
}
