#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long rev(const long long x) {
  if (x == 0) return 0;
  if (x == 1) return 1;
  return (998244353LL - 998244353LL / x) * rev(998244353LL % x) % 998244353LL;
}
long long a[55LL], w[55LL], SA, SB, revv[8 * 55LL * 55LL];
map<long long, long long> f, g;
int n, m;
long long df(int j, int i, int k, int l) {
  if (f.count(j * 55LL * 55LL * 55LL * 55LL * 55LL +
              i * 55LL * 55LL * 55LL * 55LL + k * 55LL * 55LL + l))
    return f[j * 55LL * 55LL * 55LL * 55LL * 55LL +
             i * 55LL * 55LL * 55LL * 55LL + k * 55LL * 55LL + l];
  long long c = 0;
  if (i == 0)
    c = j;
  else {
    if (j)
      c = j * revv[k + l] % 998244353LL * df(j + 1, i - 1, k + 1, l) %
          998244353LL;
    if (k > j)
      c = c + (k - j) * revv[k + l] % 998244353LL * df(j, i - 1, k + 1, l) %
                  998244353LL;
    if (l)
      c = c +
          l * revv[k + l] % 998244353LL * df(j, i - 1, k, l - 1) % 998244353LL;
  }
  c %= 998244353LL;
  f[j * 55LL * 55LL * 55LL * 55LL * 55LL + i * 55LL * 55LL * 55LL * 55LL +
    k * 55LL * 55LL + l] = c;
  return c;
}
long long dg(int j, int i, int k, int l) {
  if (g.count(j * 55LL * 55LL * 55LL * 55LL * 55LL +
              i * 55LL * 55LL * 55LL * 55LL + k * 55LL * 55LL + l))
    return g[j * 55LL * 55LL * 55LL * 55LL * 55LL +
             i * 55LL * 55LL * 55LL * 55LL + k * 55LL * 55LL + l];
  long long c = 0;
  if (i == 0)
    c = j;
  else {
    if (k)
      c = k * revv[k + l] % 998244353LL * dg(j, i - 1, k + 1, l) % 998244353LL;
    if (j)
      c = c + j * revv[k + l] % 998244353LL * dg(j - 1, i - 1, k, l - 1) %
                  998244353LL;
    if (l > j)
      c = c + (l - j) * revv[k + l] % 998244353LL * dg(j, i - 1, k, l - 1) %
                  998244353LL;
  }
  c %= 998244353LL;
  g[j * 55LL * 55LL * 55LL * 55LL * 55LL + i * 55LL * 55LL * 55LL * 55LL +
    k * 55LL * 55LL + l] = c;
  return c;
}
int main() {
  for (int i = 0; i < 8 * 55LL * 55LL; i++) revv[i] = rev(i);
  n = read();
  m = read();
  for (int i = 0; i < n; i++) a[i] = read();
  for (int i = 0; i < n; i++) w[i] = read();
  for (int i = 0; i < n; i++)
    if (a[i])
      SA += w[i];
    else
      SB += w[i];
  for (int i = 0; i < n; i++)
    if (a[i])
      printf("%lld\n", df(w[i], m, SA, SB));
    else
      printf("%lld\n", dg(w[i], m, SA, SB));
  return 0;
}
