#include <bits/stdc++.h>
using namespace std;
struct md {
  int v;
  md(int _v = 0) {
    v = _v;
    if (v < 0) v += 998244353;
  }
  md operator+=(md n) { v = (0LL + v + n.v) % 998244353; }
  md operator*=(md n) { v = (1LL * v * n.v) % 998244353; }
};
md operator+(md a, md b) {
  a += b;
  return a;
}
md operator*(md a, md b) {
  a *= b;
  return a;
}
md bigmod(md b, int i) {
  md r = 1;
  for (int j = (29); j >= (0); j--) {
    r *= r;
    if ((i >> j) & 1) r *= b;
  }
  return r;
}
md inv(int b) { return bigmod(b, 998244353 - 2); }
int love[55], wei[55];
md dp[55][55][55];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = (1); i <= (n); i++) scanf("%d", &love[i]);
  int plus = 0, minus = 0;
  for (int i = (1); i <= (n); i++) {
    scanf("%d", &wei[i]);
    if (love[i])
      plus += wei[i];
    else
      minus += wei[i];
  }
  int sum = plus + minus;
  for (int i = (1); i <= (n); i++) {
    dp[0][0][0] = 1;
    for (int j = (1); j <= (m); j++)
      for (int k = (0); k <= (j); k++)
        for (int l = (0); l <= (j - k); l++) dp[j][k][l] = 0;
    for (int j = (1); j <= (m); j++) {
      for (int k = (0); k <= (j); k++) {
        for (int l = (0); l <= (j - k); l++) {
          int delp = k + love[i] * l;
          int delm = j - delp;
          if (delm > minus) continue;
          if (k >= 1) {
            dp[j][k][l] += dp[j - 1][k - 1][l] *
                           (plus + delp - 1 - love[i] * (wei[i] + l)) *
                           inv(sum + (delp - 1) - delm);
          }
          if (delm >= !love[i] * l + 1) {
            dp[j][k][l] +=
                dp[j - 1][k][l] *
                (minus - !love[i] * wei[i] - (delm - 1 - !love[i] * l)) *
                inv(sum + delp - (delm - 1));
          }
          if (l >= 1) {
            if (love[i]) {
              dp[j][k][l] += dp[j - 1][k][l - 1] * (wei[i] + (l - 1)) *
                             inv(sum + (delp - 1) - delm);
            } else {
              dp[j][k][l] += dp[j - 1][k][l - 1] * (wei[i] - (l - 1)) *
                             inv(sum + delp - (delm - 1));
            }
          }
        }
      }
    }
    md ans = wei[i];
    for (int k = (0); k <= (m); k++)
      for (int l = (0); l <= (m - k); l++)
        ans += dp[m][k][l] * md(love[i] ? l : -l);
    printf("%d\n", ans);
  }
  return 0;
}
