#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int X = 51;
inline int qpow(int x, int y = mod - 2) {
  int res = 1;
  for (; y; y >>= 1, x = 1ll * x * x % mod)
    if (y & 1) res = 1ll * res * x % mod;
  return res;
}
int ok[X];
int val[X];
int n, m;
int dp[X][X][X];
int init_like, init_hate;
int now;
int inv[X * X + X];
int dfs(int step, int like, int hate) {
  if (~dp[step][like][hate]) return dp[step][like][hate];
  if (step == 0) return dp[step][like][hate] = (like || hate) ? 0 : 1;
  int ans = 0;
  int special = step - like - hate;
  int sp = val[now] + special * ok[now];
  int li = like + init_like - ((ok[now] == 1) ? val[now] : 0);
  int ha = -hate + init_hate - ((ok[now] == 1) ? 0 : val[now]);
  int totweight = sp + li + ha;
  if (special > 0)
    ans = (ans + 1ll * dfs(step - 1, like, hate) * (sp - ok[now]) % mod *
                     inv[totweight - ok[now]]) %
          mod;
  if (like > 0)
    ans = (ans + 1ll * dfs(step - 1, like - 1, hate) * (li - 1) % mod *
                     inv[totweight - 1]) %
          mod;
  if (hate > 0)
    ans = (ans + 1ll * dfs(step - 1, like, hate - 1) * (ha + 1) % mod *
                     inv[totweight + 1]) %
          mod;
  return dp[step][like][hate] = ans;
}
int main() {
  cin >> n >> m;
  for (int i = 1, c; i <= n; i++) {
    cin >> c;
    ok[i] = c ? 1 : -1;
  }
  for (int i = 1; i <= n; i++) {
    cin >> val[i];
    if (ok[i] == 1)
      init_like += val[i];
    else
      init_hate += val[i];
  }
  for (int i = 1; i <= init_like + init_hate + m; i++) inv[i] = qpow(i);
  for (now = 1; now <= n; now++) {
    memset(dp, -1, sizeof(dp));
    int ans = 0;
    for (int like = 0; like <= m; like++)
      for (int hate = 0; hate <= m - like; hate++) {
        int special = m - like - hate;
        ans =
            (ans + 1ll * (val[now] + special * ok[now]) * dfs(m, like, hate)) %
            mod;
      }
    cout << ans << endl;
  }
}
