#include <bits/stdc++.h>
using namespace std;
const int MAXN = 53;
const int MOD = 998244353;
int invs[10 * MAXN];
int add(int a, int b) {
  long long res = (long long)a + b;
  return res % MOD;
}
int sub(int a, int b) {
  long long res = (long long)a - b;
  res %= MOD;
  res += MOD;
  return res % MOD;
}
int mul(int a, int b) {
  long long res = (long long)a * b;
  return res % MOD;
}
int binpow(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
void init() {
  for (int i = 0; i < 10 * MAXN; i++) {
    invs[i] = binpow(i, MOD - 2);
  }
}
int inv(int a) {
  if (a < 10 * MAXN) {
    return invs[a];
  } else {
    return binpow(a, MOD - 2);
  }
}
int divv(int a, int b) { return mul(a, inv(b)); }
int n, m;
int SA, SB;
int dp[MAXN][MAXN][MAXN];
int sw;
void relax_like(int dw, int sa, int sb) {
  int sum_like = SA + sa;
  int sum_disl = SB - sb;
  int w = sw + dw;
  {
    int prob = divv(w, sum_like + sum_disl);
    dp[dw + 1][sa + 1][sb] =
        add(dp[dw + 1][sa + 1][sb], mul(dp[dw][sa][sb], prob));
  }
  {
    int prob = divv(sum_like - w, sum_like + sum_disl);
    dp[dw][sa + 1][sb] = add(dp[dw][sa + 1][sb], mul(dp[dw][sa][sb], prob));
  }
  {
    int prob = divv(sum_disl, sum_like + sum_disl);
    dp[dw][sa][sb + 1] = add(dp[dw][sa][sb + 1], mul(dp[dw][sa][sb], prob));
  }
}
void relax_dislike(int dw, int sa, int sb) {
  int sum_like = SA + sa;
  int sum_disl = SB - sb;
  int w = sw - dw;
  if (w > 0) {
    int prob = divv(w, sum_like + sum_disl);
    dp[dw + 1][sa][sb + 1] =
        add(dp[dw + 1][sa][sb + 1], mul(dp[dw][sa][sb], prob));
  }
  {
    int prob = divv(sum_disl - w, sum_like + sum_disl);
    dp[dw][sa][sb + 1] = add(dp[dw][sa][sb + 1], mul(dp[dw][sa][sb], prob));
  }
  {
    int prob = divv(sum_like, sum_like + sum_disl);
    dp[dw][sa + 1][sb] = add(dp[dw][sa + 1][sb], mul(dp[dw][sa][sb], prob));
  }
}
int solve_one(int sw_, int lk) {
  sw = sw_;
  for (int i = 0; i < MAXN; i++) {
    for (int j = 0; j < MAXN; j++) {
      for (int k = 0; k < MAXN; k++) {
        dp[i][j][k] = 0;
      }
    }
  }
  dp[0][0][0] = 1;
  for (int d = 0; d < m; d++) {
    for (int sa = 0; sa <= d; sa++) {
      int sb = d - sa;
      for (int w = 0; w + 1 < MAXN; w++) {
        if (lk) {
          relax_like(w, sa, sb);
        } else {
          relax_dislike(w, sa, sb);
        }
      }
    }
  }
  int ans = 0;
  for (int ew = 0; ew < MAXN; ew++) {
    for (int sa = 0; sa <= m; sa++) {
      int sb = m - sa;
      if (lk) {
        ans = add(ans, mul(ew, dp[ew][sa][sb]));
      } else {
        ans = sub(ans, mul(ew, dp[ew][sa][sb]));
      }
    }
  }
  return add(sw, ans);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  init();
  cin >> n >> m;
  vector<int> a(n);
  for (auto &t : a) {
    cin >> t;
  }
  vector<int> w(n);
  for (auto &t : w) {
    cin >> t;
  }
  SA = 0;
  SB = 0;
  for (int i = 0; i < n; i++) {
    if (a[i]) {
      SA += w[i];
    } else {
      SB += w[i];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << solve_one(w[i], a[i]) << '\n';
  }
}
