#include <bits/stdc++.h>
using namespace std;
const int maxm = 3001;
const int maxn = 2e6;
const long long mod = 998244353;
long long add(long long a, long long b) { return (a + b) % mod; }
long long sub(long long a, long long b) { return ((a - b) % mod + mod) % mod; }
long long mul(long long a, long long b) { return (a * b) % mod; }
long long ldp[maxm][maxm], ddp[maxm][maxm], tl, tdl;
int n, m, like[maxn], weight[maxn];
long long power(long long a, long long b, long long m) {
  if (b == 0) return 1;
  long long tmp = power(a, b / 2, m);
  tmp = (tmp * tmp) % m;
  if (b & 1) tmp = (tmp * a) % m;
  return tmp;
}
long long disp[10000], st;
void preInv() {
  st = tl + tdl + 5000;
  for (int i = 0; i < 10000; i++) {
    if (i > st) break;
    disp[i] = power(st - i, mod - 2, mod);
  }
}
long long inv(long long a) { return disp[st - a]; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> like[i];
  for (int i = 1; i <= n; i++) {
    cin >> weight[i];
    if (like[i])
      tl += weight[i];
    else
      tdl += weight[i];
  }
  preInv();
  for (int i = 0; i <= m; i++) {
    if ((m - i) > tdl) continue;
    ldp[i][m - i] = 1;
    ddp[i][m - i] = 1;
  }
  for (int i = m - 1; i >= 0; i--) {
    for (int j = min(m - i - 1LL, tdl); j >= 0; j--) {
      ldp[i][j] =
          add(mul(2, mul(ldp[i + 1][j], inv(tl + i + max(0LL, tdl - j)))),
              add(mul(tl + i - 1,
                      mul(ldp[i + 1][j], inv(tl + i + max(0LL, tdl - j)))),
                  mul(max(0LL, tdl - j),
                      mul(ldp[i][j + 1], inv(tl + i + max(0LL, tdl - j))))));
      ddp[i][j] =
          add(mul(max(0LL, tdl - j - 1),
                  mul(ddp[i][j + 1], inv(tl + i + max(0LL, tdl - j)))),
              mul(tl + i, mul(ddp[i + 1][j], inv(tl + i + max(0LL, tdl - j)))));
    }
  }
  for (int i = 1; i <= n; i++) {
    if (like[i]) {
      cout << mul(weight[i], ldp[0][0]) << "\n";
    } else {
      cout << mul(weight[i], ddp[0][0]) << "\n";
    }
  }
  return 0;
}
