#include <bits/stdc++.h>
using namespace std;
int M = 998244353;
int pow(int a, int b) {
  if (b == 0) {
    return 1;
  }
  if (b % 2) {
    return ((long long)a * pow(a, b - 1)) % M;
  } else {
    int temp = pow(a, b / 2);
    return ((long long)temp * temp) % M;
  }
}
int inv[3010];
int w[55];
int a[55];
int dp1[55][55][55];
int dp2[55][55][55];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < 3010; i++) {
    inv[i] = pow(i, M - 2);
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int s = 0, s1 = 0, s2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    s += w[i];
    if (a[i]) {
      s1 += w[i];
    }
  }
  s2 = s - s1;
  for (int i = 0; i < n; i++) {
    dp1[i][0][0] = 1;
  }
  for (int l = 0; l < m; l++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 55; j++) {
        for (int k = 0; k < 55; k++) {
          if (a[i]) {
            dp2[i][j][k] = (long long)dp1[i][j][k] * (s2 - l + j) % M *
                           inv[s + 2 * j - l] % M;
            if (k && j)
              dp2[i][j][k] = (dp2[i][j][k] + (long long)dp1[i][j - 1][k - 1] *
                                                 (w[i] + k - 1) % M *
                                                 inv[s + 2 * j - l - 2] % M) %
                             M;
            if (j)
              dp2[i][j][k] = (dp2[i][j][k] + (long long)dp1[i][j - 1][k] *
                                                 (s1 + j - w[i] - k - 1) % M *
                                                 inv[s + 2 * j - 2 - l] % M) %
                             M;
          } else {
            dp2[i][j][k] = (long long)dp1[i][j][k] * (s2 - l + j - (w[i] - k)) %
                           M * inv[s + 2 * j - l] % M;
            if (k)
              dp2[i][j][k] = (dp2[i][j][k] + (long long)dp1[i][j][k - 1] *
                                                 (w[i] - (k - 1)) % M *
                                                 inv[s + 2 * j - l] % M) %
                             M;
            if (j)
              dp2[i][j][k] =
                  (dp2[i][j][k] + (long long)dp1[i][j - 1][k] * (s1 + j - 1) %
                                      M * inv[s + 2 * j - 2 - l] % M) %
                  M;
          }
        }
      }
    }
    for (int i = 0; i < 55; i++) {
      for (int j = 0; j < 55; j++) {
        for (int k = 0; k < 55; k++) {
          dp1[i][j][k] = dp2[i][j][k];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < 55; j++) {
      for (int k = 0; k < 55; k++) {
        if (a[i]) {
          int temp = (long long)(w[i] + k) * dp1[i][j][k] % M;
          ans = (ans + temp) % M;
        } else {
          int temp = (long long)(w[i] - k) * dp1[i][j][k] % M;
          ans = (ans + temp) % M;
        }
      }
    }
    cout << ans << endl;
  }
}
