#include <bits/stdc++.h>
using namespace std;
long long power(long long first, long long second) {
  long long ret = 1;
  for (; second; second >>= 1) {
    if (second & 1) ret = ret * first % 998244353;
    first = first * first % 998244353;
  }
  return ret;
}
long long frac(long long first, long long second) {
  return first * power(second, 998244353 - 2) % 998244353;
}
int n, m;
int a[20005], b[20005], goodw, badw;
long long dp[55][55][55];
void solve(int first) {
  memset(dp, 0, sizeof dp);
  dp[0][0][0] = 1;
  if (a[first]) {
    for (int i = 0; i < m; i++) {
      for (int j = 0; j <= min(badw, i); j++) {
        const int gt = i - j, bt = j;
        const long long goodpos = frac(goodw + gt, goodw + badw + gt - bt);
        const long long badpos = frac(badw - bt, goodw + badw + gt - bt);
        for (int k = 0; k <= gt; k++)
          if (dp[i][j][k]) {
            (dp[i + 1][j][k] +=
             dp[i][j][k] * goodpos % 998244353 *
             frac(goodw + gt - (b[first] + k), goodw + gt)) %= 998244353;
            (dp[i + 1][j][k + 1] += dp[i][j][k] * goodpos % 998244353 *
                                    frac(b[first] + k, goodw + gt)) %=
                998244353;
            (dp[i + 1][j + 1][k] += dp[i][j][k] * badpos) %= 998244353;
          }
      }
    }
  } else {
    for (int i = 0; i < m; i++) {
      for (int j = 0; j <= min(badw, i); j++) {
        const int gt = i - j, bt = j;
        const long long goodpos = frac(goodw + gt, goodw + badw + gt - bt);
        const long long badpos = frac(badw - bt, goodw + badw + gt - bt);
        for (int k = 0; k <= bt; k++)
          if (dp[i][j][k]) {
            (dp[i + 1][j + 1][k] +=
             dp[i][j][k] * badpos % 998244353 *
             frac(badw - bt - (b[first] - k), badw - bt)) %= 998244353;
            (dp[i + 1][j + 1][k + 1] += dp[i][j][k] * badpos % 998244353 *
                                        frac((b[first] - k), badw - bt)) %=
                998244353;
            (dp[i + 1][j][k] += dp[i][j][k] * goodpos) %= 998244353;
          }
      }
    }
  }
  long long ans = 0;
  for (int j = 0; j <= m; j++) {
    for (int k = 0; k <= m; k++)
      if (dp[m][j][k]) {
        (ans += dp[m][j][k] * k) %= 998244353;
      }
  }
  printf("%lld\n",
         (998244353 + (a[first] ? ans : -ans) + b[first]) % 998244353);
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (a[i])
      goodw += b[i];
    else
      badw += b[i];
  }
  for (int i = 1; i <= n; i++) solve(i);
}
