#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
template <typename T>
bool mmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T>
bool mmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}
void __print(long long first) { cerr << first; }
void __print(long first) { cerr << first; }
void __print(unsigned first) { cerr << first; }
void __print(unsigned long first) { cerr << first; }
void __print(unsigned long long first) { cerr << first; }
void __print(float first) { cerr << first; }
void __print(double first) { cerr << first; }
void __print(long double first) { cerr << first; }
void __print(char first) { cerr << '\'' << first << '\''; }
void __print(const char *first) { cerr << '\"' << first << '\"'; }
void __print(const string &first) { cerr << '\"' << first << '\"'; }
void __print(bool first) { cerr << (first ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &first) {
  cerr << '{';
  __print(first.first);
  cerr << ',';
  __print(first.second);
  cerr << '}';
}
template <typename T>
void __print(const T &first) {
  long long f = 0;
  cerr << '{';
  for (auto &i : first) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
std::mt19937 rng(
    (long long)std::chrono::steady_clock::now().time_since_epoch().count());
const long long N = 51, M = (1 << 18);
long long modinv[M], w[2], a[N], wt[N], n, m;
long long dp[N][N][N];
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = res * a;
      res %= 998244353;
    }
    a = a * a;
    a %= 998244353;
    b = b / 2;
  }
  return res;
}
long long inverse(long long first) {
  if (modinv[first] != 0) return modinv[first];
  return modinv[first] = power(first, 998244353 - 2);
}
long long sg(long long i) {
  if (a[i])
    return 1;
  else
    return -1;
}
void add(long long &a, long long b) {
  a += b;
  if (a >= 998244353) a -= 998244353;
}
void calc(long long cur) {
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  w[a[cur]] -= wt[cur];
  for (long long i = (long long)(0); i <= (long long)(m - 1); ++i) {
    for (long long j = (long long)(0); j <= (long long)(m); ++j) {
      for (long long k = 0; j + k <= i; k++) {
        long long d = sg(cur) * (i - j - k) + wt[cur];
        if (d < 0 || w[0] - j < 0) continue;
        long long f = inverse(d + w[0] - j + w[1] + k);
        add(dp[i + 1][j][k],
            (dp[i][j][k] * (d * f % 998244353) % 998244353) % 998244353);
        add(dp[i + 1][j + 1][k],
            (dp[i][j][k] * ((w[0] - j) * f % 998244353) % 998244353) %
                998244353);
        add(dp[i + 1][j][k + 1],
            (dp[i][j][k] * ((w[1] + k) * f % 998244353) % 998244353) %
                998244353);
      }
    }
  }
  long long ans = 0;
  for (long long j = (long long)(0); j <= (long long)(m); ++j) {
    for (long long k = 0; j + k <= m; k++) {
      add(ans, (dp[m][j][k] * ((m - j - k) * sg(cur) + wt[cur])) % 998244353);
    }
  }
  cout << ans << "\n";
  w[a[cur]] += wt[cur];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n >> m;
  for (long long i = (long long)(1); i <= (long long)(n); ++i) {
    cin >> a[i];
  }
  for (long long i = (long long)(1); i <= (long long)(n); ++i) {
    cin >> wt[i];
    w[a[i]] += wt[i];
  }
  for (long long i = (long long)(1); i <= (long long)(n); ++i) {
    calc(i);
  }
  return 0;
}
