#include <bits/stdc++.h>
using namespace std;
int a[55];
int w[55];
int dp[55][55][55];
int inv[100005];
int main() {
  inv[1] = 1;
  for (int i = 2; i <= 100000; i++) {
    inv[i] = 1LL * (998244353 - 998244353 / i) * inv[998244353 % i] % 998244353;
  }
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  int sum1 = 0, sum2 = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1)
      sum1 += w[i];
    else
      sum2 += w[i];
  }
  for (int id = 1; id <= n; id++) {
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    int flag = 1;
    if (a[id] == 1) {
      for (int i = 0; i <= m; i++)
        for (int j = 0; j <= m; j++)
          for (int k = j; k <= m; k++) {
            if (dp[i][j][k] == 0) continue;
            int tt = sum1 + sum2 + k - (i - k);
            dp[i + 1][j + 1][k + 1] += 1LL * dp[i][j][k] * inv[tt] % 998244353 *
                                       (w[id] + j) % 998244353;
            dp[i + 1][j + 1][k + 1] % 998244353;
            dp[i + 1][j][k + 1] += 1LL * dp[i][j][k] * inv[tt] % 998244353 *
                                   (sum1 + k - (w[id] + j)) % 998244353;
            dp[i + 1][j][k + 1] %= 998244353;
            if (sum2 - (i - k) > 0)
              dp[i + 1][j][k] += 1LL * dp[i][j][k] * inv[tt] % 998244353 *
                                 (sum2 - (i - k)) % 998244353;
            dp[i + 1][j][k] %= 998244353;
          }
    } else {
      for (int i = 0; i <= m; i++)
        for (int j = 0; j <= min(m, w[id]); j++)
          for (int k = j; k <= m; k++) {
            if (dp[i][j][k] == 0) continue;
            int tt = sum1 + sum2 - k + (i - k);
            dp[i + 1][j + 1][k + 1] += 1LL * dp[i][j][k] * inv[tt] % 998244353 *
                                       (w[id] - j) % 998244353;
            dp[i + 1][j + 1][k + 1] %= 998244353;
            if (sum2 - k - (w[id] - j) > 0)
              dp[i + 1][j][k + 1] += 1LL * dp[i][j][k] * inv[tt] % 998244353 *
                                     (sum2 - k - (w[id] - j)) % 998244353;
            dp[i + 1][j][k + 1] %= 998244353;
            dp[i + 1][j][k] += 1LL * dp[i][j][k] * inv[tt] % 998244353 *
                               (sum1 + (i - k)) % 998244353;
            dp[i + 1][j][k] %= 998244353;
          }
    }
    long long ans = 0;
    for (int j = 0; j <= m; j++) {
      long long p = 0;
      for (int k = j; k <= m; k++) {
        p = p + dp[m][j][k];
        p %= 998244353;
      }
      if (a[id] == 1)
        ans = ans + 1LL * p * (w[id] + j) % 998244353;
      else
        ans = ans + 1LL * p * (w[id] - j) % 998244353;
      ans %= 998244353;
      (ans += 998244353) %= 998244353;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
