#include <bits/stdc++.h>
using namespace std;
ifstream in;
ofstream out;
const long long kk = 1000;
const long long ml = kk * kk;
const long long mod = 998244353;
const long long inf = ml * ml * ml + 7;
long long n, i, j, pos;
vector<long long> w;
vector<bool> t;
long long s[2];
bool viv = false;
long long obr(long long v, long long mod) {
  long long i = 0;
  long long st = mod - 2;
  vector<long long> bin;
  long long l = 0;
  while (st > 0) {
    bin.push_back(st & 1);
    st /= 2;
    l++;
  }
  vector<long long> sq;
  sq.push_back(v);
  for (i = 1; i < l; i++) {
    long long s = sq.back();
    s *= s;
    s %= mod;
    sq.push_back(s);
  }
  long long ans = 1;
  for (i = 0; i < l; i++)
    if (bin[i]) {
      ans *= sq[i];
      ans %= mod;
    }
  return ans;
}
pair<long long, pair<long long, long long> > con(long long a, long long b,
                                                 long long c) {
  return {a, {b, c}};
}
pair<long long, long long> umn(pair<long long, long long> a,
                               pair<long long, long long> b) {
  a.first *= b.first;
  a.first %= mod;
  a.second *= b.second;
  a.second %= mod;
  return a;
}
pair<long long, long long> sum(pair<long long, long long> a,
                               pair<long long, long long> b) {
  a.first *= b.second;
  b.first *= a.second;
  a.second *= b.second;
  a.first += b.first;
  a.first %= mod;
  a.second %= mod;
  return a;
}
long long solve(long long m, long long b, long long g, bool good) {
  map<pair<long long, pair<long long, long long> >, pair<long long, long long> >
      mp[pos + 1];
  mp[0][con(m, b, g)] = {1, 1};
  for (long long i = 0; i < pos; i++) {
    if (viv) cout << "I wait " << mp[i].size() << endl;
    for (pair<pair<long long, pair<long long, long long> >,
              pair<long long, long long> >
             v : mp[i]) {
      pair<long long, long long> val = v.second;
      long long a = v.first.first;
      long long b = v.first.second.first;
      long long c = v.first.second.second;
      long long all = a + b + c;
      if (viv)
        cout << "Have on " << i << " step " << '{' << a << ' ' << b << ' ' << c
             << '}' << ' ' << val.first << "/" << val.second << endl;
      if (a)
        if (mp[i + 1].find(con(a - 1 + 2 * good, b, c)) == mp[i + 1].end())
          mp[i + 1][con(a - 1 + 2 * good, b, c)] = umn(val, {a, all});
        else
          mp[i + 1][con(a - 1 + 2 * good, b, c)] =
              sum(mp[i + 1][con(a - 1 + 2 * good, b, c)], umn(val, {a, all}));
      if (b)
        if (mp[i + 1].find(con(a, b - 1, c)) == mp[i + 1].end())
          mp[i + 1][con(a, b - 1, c)] = umn(val, {b, all});
        else
          mp[i + 1][con(a, b - 1, c)] =
              sum(mp[i + 1][con(a, b - 1, c)], umn(val, {b, all}));
      if (c)
        if (mp[i + 1].find(con(a, b, c + 1)) == mp[i + 1].end())
          mp[i + 1][con(a, b, c + 1)] = umn(val, {c, all});
        else
          mp[i + 1][con(a, b, c + 1)] =
              sum(mp[i + 1][con(a, b, c + 1)], umn(val, {c, all}));
      if (viv) cout << "MMMM" << endl;
    }
    if (viv) cout << "VSE" << endl;
  }
  if (viv)
    cout << "Sovsem VSE" << endl, cout << "We saw " << mp[pos].size() << endl;
  pair<long long, long long> res = {0, 1};
  for (pair<pair<long long, pair<long long, long long> >,
            pair<long long, long long> >
           v : mp[pos]) {
    if (viv)
      cout << "Have on last step " << '{' << v.first.first << ' '
           << v.first.second.first << ' ' << v.first.second.second << '}' << ' '
           << v.second.first << "/" << v.second.second << endl;
    res = sum(res, umn(v.second, {v.first.first, 1}));
  }
  long long lans = res.first;
  lans *= obr(res.second, mod);
  lans %= mod;
  return lans;
}
long long sol(long long num) {
  long long ls[2];
  ls[0] = s[0];
  ls[1] = s[1];
  ls[t[num]] -= w[num];
  return solve(w[num], ls[0], ls[1], t[num]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> pos;
  for (i = 0; i < n; i++) {
    long long a;
    cin >> a;
    t.push_back(a);
  }
  for (i = 0; i < n; i++) {
    long long a;
    cin >> a;
    s[t[i]] += a;
    w.push_back(a);
  }
  vector<long long> ans;
  for (long long i = 0; i < n; i++) ans.push_back(sol(i));
  for (auto i : ans) cout << i << '\n';
  return 0;
}
