#include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
inline long long Msum(long long x) { return x; }
template <typename... Rest>
inline long long Msum(long long x, Rest... rest) {
  return (x + Msum(rest...)) % MOD;
}
inline long long Mprod(long long x) { return x; }
template <typename... Rest>
inline long long Mprod(long long x, Rest... rest) {
  return x * Mprod(rest...) % MOD;
}
inline long long Mnorm(long long x) { return (x % MOD + MOD) % MOD; }
long long Msq(long long x) { return x * x % MOD; }
long long Mpow(long long b, long long e) {
  return e ? Mprod(Msq(Mpow(b, e >> 1)), (e & 1 ? b : 1)) : 1;
}
long long Minv(long long x) { return Mpow(x, MOD - 2); }
const int MAXN = 51;
int sns[MAXN], w[MAXN];
int wi, sn;
int sl, sd, S;
long long dp[MAXN][MAXN][MAXN];
long long f(int h, int hl, int hd, int t) {
  if (!t) return 0;
  long long &ret = dp[h][hl][hd];
  if (ret != -1) return ret;
  ret = 0;
  long long cS = S + hl - hd + sn * h;
  ret += Mprod(wi + sn * h, Minv(cS), 1 + f(h + 1, hl, hd, t - 1));
  ret = Mnorm(ret);
  ret += Mprod(sl + hl, Minv(cS), f(h, hl + 1, hd, t - 1));
  ret = Mnorm(ret);
  ret += Mprod(sd - hd, Minv(cS), f(h, hl, hd + 1, t - 1));
  ret = Mnorm(ret);
  assert(sd - hd + sl + hl + wi + sn * h == cS);
  return ret;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &sns[i]);
    sns[i] = sns[i] * 2 - 1;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
  }
  for (int i = 0; i < n; i++) {
    S = sl = sd = 0;
    wi = w[i];
    sn = sns[i];
    for (int j = 0; j < (int)n; j++) {
      S += w[j];
      if (j != i) {
        if (sns[j] == 1)
          sl += w[j];
        else
          sd += w[j];
      }
    }
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", Mnorm(wi + sn * f(0, 0, 0, m)));
  }
}
