#include <bits/stdc++.h>
using namespace std;
long long inv(long long a, long long mod) {
  long long b = mod, p = 1, q = 0;
  while (b) {
    long long c = a / b, d = a;
    a = b;
    b = d % b;
    d = p;
    p = q;
    q = d - c * q;
  }
  return (p + mod) % mod;
}
map<tuple<long long, long long, long long, long long, int>, long long> mp;
long long sol(long long w0, long long w1, long long w2, long long a, int m) {
  long long res = 0;
  long long mod = 998244353;
  tuple<long long, long long, long long, long long, int> key =
      make_tuple(w0, w1, w2, a, m);
  if (mp.find(key) != mp.end()) return mp[key];
  if (m == 0) {
    res = w2;
  } else {
    long long sum = w0 + w1 + w2;
    long long isum = inv(sum, mod);
    long long t0 = w0 * isum % mod * sol(w0 - 1, w1, w2, a, m - 1) % mod;
    long long t1 = w1 * isum % mod * sol(w0, w1 + 1, w2, a, m - 1) % mod;
    long long t2 =
        w2 * isum % mod * sol(w0, w1, w2 + (a == 0 ? -1 : 1), a, m - 1) % mod;
    res = (t0 + t1 + t2) % mod;
  }
  mp[key] = res;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<long long> a(n), w(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> w[i];
  long long mod = 998244353;
  vector<long long> res(n);
  for (int i = 0; i < n; i++) {
    long long w0 = 0, w1 = 0;
    for (int j = 0; j < n; j++) {
      if (j == i) continue;
      if (a[j] == 0)
        w0 = (w0 + w[j]) % mod;
      else
        w1 = (w1 + w[j]) % mod;
    }
    long long w2 = w[i];
    res[i] = sol(w0, w1, w2, a[i], m);
  }
  for (int i = 0; i < n; i++) {
    cout << res[i] << "\n";
  }
  return 0;
}
