#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000024;
int a[64], w[64], tw, w0, w1;
int v[64][64][64][64];
long long dp[64][64][64][64];
void exgcd(long long a, long long b, long long& d, long long& x, long long& y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    exgcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
long long __inv(long long a, long long p) {
  long long d, x, y;
  exgcd(a, p, d, x, y);
  return d == 1 ? (x + p) % p : -1;
}
long long inv(long long a) { return __inv(a, 998244353); }
long long ddp(int i, int k, int m, int mp) {
  if (k < 0 || m < 0 || mp < 0) return 0LL;
  if (v[i][k][m][mp]) return dp[i][k][m][mp];
  v[i][k][m][mp] = 1;
  if (k == 0 && m == 0 && mp == 0) return dp[i][k][m][mp] = 1LL;
  if (a[i] == 1) {
    dp[i][k][m][mp] = 0LL;
    dp[i][k][m][mp] += ddp(i, k - 1, m - 1, mp - 1) * (w[i] + (k - 1)) %
                       998244353 * inv(tw + (mp - 1) - (m - mp)) % 998244353;
    dp[i][k][m][mp] %= 998244353;
    dp[i][k][m][mp] += ddp(i, k, m - 1, mp) * (w0 - (m - 1 - mp)) % 998244353 *
                       inv(tw + (mp) - (m - 1 - mp)) % 998244353;
    dp[i][k][m][mp] %= 998244353;
    dp[i][k][m][mp] += ddp(i, k, m - 1, mp - 1) * (w1 + (mp - 1) - (w[i] + k)) %
                       998244353 * inv(tw + (mp - 1) - (m - mp)) % 998244353;
    dp[i][k][m][mp] %= 998244353;
  } else {
    dp[i][k][m][mp] = 0LL;
    dp[i][k][m][mp] += ddp(i, k - 1, m - 1, mp) * (w[i] - (k - 1)) % 998244353 *
                       inv(tw + mp - (m - 1 - mp)) % 998244353;
    dp[i][k][m][mp] %= 998244353;
    dp[i][k][m][mp] += ddp(i, k, m - 1, mp) * (w0 - (m - 1 - mp) - (w[i] - k)) %
                       998244353 * inv(tw + mp - (m - 1 - mp)) % 998244353;
    dp[i][k][m][mp] %= 998244353;
    dp[i][k][m][mp] += ddp(i, k, m - 1, mp - 1) * (w1 + mp - 1) % 998244353 *
                       inv(tw + (mp - 1) - (m - mp)) % 998244353;
    dp[i][k][m][mp] %= 998244353;
  }
  return dp[i][k][m][mp];
}
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    memset(v, 0, sizeof v);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    tw = 0, w0 = 0, w1 = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &w[i]), tw += w[i];
      if (a[i] == 1)
        w1 += w[i];
      else
        w0 += w[i];
    }
    for (int i = 1; i <= n; i++) {
      long long ans = 0LL;
      for (int k = 0; k <= m; k++)
        for (int mp = 0; mp <= m; mp++) {
          ans += ddp(i, k, m, mp) * (w[i] + (a[i] == 1 ? 1 : -1) * k);
          ans %= 998244353;
        }
      cout << ans << endl;
    }
  }
  return 0;
}
