#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 50;
int isgood[N], w[N];
int n, m;
long long power(long long a, long long b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b & 1) {
      x = (x * y);
      if (x > MOD) x %= MOD;
    }
    y = y * y;
    if (y > MOD) y %= MOD;
    b >>= 1;
  }
  return x;
}
int inv(int x) { return power(x, MOD - 2); }
int mul(int x, int y) { return 1LL * x * y % MOD; }
int add(int x, int y) {
  int ret = x + y;
  if (ret >= MOD) ret -= MOD;
  return ret;
}
map<pair<pair<int, int>, pair<int, int> >, int> map1;
int solve2(int idx, int me, int g, int b, bool flag) {
  if (idx == m) return me;
  if (map1.find(make_pair(make_pair(idx, me), make_pair(g, b))) != map1.end())
    return map1[{{idx, me}, {g, b}}];
  int ret = mul(mul(g, inv(g + b + me)), solve2(idx + 1, me, g + 1, b, flag));
  if (b)
    ret = add(
        ret, mul(mul(b, inv(g + b + me)), solve2(idx + 1, me, g, b - 1, flag)));
  if (flag || me)
    ret = add(ret, mul(mul(me, inv(g + b + me)),
                       solve2(idx + 1, me + (flag ? 1 : -1), g, b, flag)));
  return map1[{{idx, me}, {g, b}}] = ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  int g = 0, b = 0;
  for (int i = 0; i < int(n); i++) cin >> isgood[i];
  for (int i = 0; i < int(n); i++) cin >> w[i];
  for (int i = 0; i < int(n); i++) {
    if (isgood[i])
      g += w[i];
    else
      b += w[i];
  }
  for (int i = 0; i < int(n); i++) {
    int cur = solve2(0, w[i], g - (isgood[i] ? w[i] : 0),
                     b - (isgood[i] ? 0 : w[i]), isgood[i]);
    cout << cur << '\n';
  }
  return 0;
}
