#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005, mod = 998244353;
long long dp[maxn][maxn], inv[6005], t1, t2;
void add(long long &x, long long y) { x = (x + y) % mod; }
long long ksm(long long x, int y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y /= 2;
  }
  return res;
}
const int N = 2e5 + 10;
int a[N], w[N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
    if (a[i])
      t1 += w[i];
    else
      t2 += w[i];
  }
  for (int i = 1; i <= 2 * m; i++) inv[i] = ksm(t1 + t2 - (m - i), mod - 2);
  dp[0][0] = 1;
  long long ans1 = 0, ans2 = 0;
  for (int M = 0; M <= m; M++)
    for (int i = 0; i <= M; i++) {
      int j = M - i;
      long long res = t1 + i;
      long long sum = i - j;
      if (t2 - j < 0) continue;
      if (M == m) {
        add(ans1, dp[i][j] * (t1 + i) % mod);
        add(ans2, dp[i][j] * (t2 - j) % mod);
      }
      add(dp[i + 1][j], dp[i][j] * res % mod * inv[sum + m]);
      if (t2 - j >= 0)
        add(dp[i][j + 1], dp[i][j] * (t2 - j) % mod * inv[sum + m]);
    }
  for (int i = 1; i <= n; i++) {
    if (a[i]) {
      long long tmp = 1ll * w[i] * ksm(t1, mod - 2) % mod * ans1 % mod;
      cout << tmp << endl;
    } else {
      long long tmp = 1ll * w[i] * ksm(t2, mod - 2) % mod * ans2 % mod;
      cout << tmp << endl;
    }
  }
}
