#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int M = 3010;
int n, m, arr[N], good[N], inv[M * 2], inv2[M * 2], inv3[M * 3];
int fres = 1, sum = 0, sum_of_good = 0, sum_of_bad = 0;
int dp[M][M], dp2[M][M];
inline int fastpower(int num, int po) {
  fres = 1;
  while (po > 0) {
    if (po & 1) fres = (long long)fres * num % 998244353;
    num = (long long)num * num % 998244353;
    po >>= 1;
  }
  return fres;
}
int tmp1, tmp2, tmp3;
inline int go_good(int i, int j) {
  tmp1 = sum_of_good + j;
  tmp2 = sum_of_bad - (i - j);
  if (tmp2 < 0) return 0;
  return (long long)tmp1 * inv[tmp1 + tmp2 - sum + M] % 998244353;
}
inline int go_bad(int i, int j) {
  tmp1 = sum_of_good + j;
  tmp2 = sum_of_bad - (i - j);
  if (tmp2 < 0) return 0;
  return (long long)tmp2 * inv[tmp1 + tmp2 - sum + M] % 998244353;
}
int calc_good(int num) {
  dp2[0][0] = 1;
  int ans = 0;
  int s = 0, pre = 0;
  for (int i = 1; i <= m; i++) {
    if (i != 1) {
      s += pre;
      if (s >= 998244353) s -= 998244353;
      ans += (long long)dp[m][i] * s % 998244353;
      if (ans >= 998244353) ans -= 998244353;
      continue;
    }
    s = 0;
    for (int j = 0; j <= i; j++) {
      dp2[i][j] = 0;
      tmp1 = sum_of_good + i - 1;
      tmp2 = (long long)(num + j - 1) * inv2[tmp1 - sum_of_good] % 998244353;
      if (j) dp2[i][j] = (long long)dp2[i - 1][j - 1] * tmp2 % 998244353;
      tmp2 =
          (long long)(tmp1 - (num + j)) * inv2[tmp1 - sum_of_good] % 998244353;
      if (j != i) dp2[i][j] += (long long)dp2[i - 1][j] * tmp2 % 998244353;
      if (dp2[i][j] >= 998244353) dp2[i][j] -= 998244353;
      s += (long long)j * dp2[i][j] % 998244353;
      if (s >= 998244353) s -= 998244353;
      tmp2 = (long long)dp2[i][j] * dp[m][i] % 998244353;
      ans += (long long)tmp2 * j % 998244353;
      if (ans >= 998244353) ans -= 998244353;
    }
    pre = s;
  }
  return ans;
}
int calc_bad(int num) {
  dp2[0][0] = 1;
  int ans = 0;
  int s = 0, pre = 1;
  for (int i = 1; i <= min(m, sum_of_bad); i++) {
    if (i != 1) {
      s += pre;
      if (s >= 998244353) s -= 998244353;
      ans += (long long)dp[m][m - i] * s % 998244353;
      if (ans >= 998244353) ans -= 998244353;
      continue;
    }
    s = 0;
    for (int j = 0; j <= i; j++) {
      dp2[i][j] = 0;
      tmp1 = sum_of_bad - (i - 1);
      tmp2 = (long long)(num - (j - 1)) * inv3[sum_of_bad - tmp1] % 998244353;
      if (j) dp2[i][j] = (long long)dp2[i - 1][j - 1] * tmp2 % 998244353;
      tmp2 =
          (long long)(tmp1 - (num - j)) * inv3[sum_of_bad - tmp1] % 998244353;
      if (j != i) dp2[i][j] += (long long)dp2[i - 1][j] * tmp2 % 998244353;
      if (dp2[i][j] >= 998244353) dp2[i][j] -= 998244353;
      s += (long long)j * dp2[i][j] % 998244353;
      if (s >= 998244353) s -= 998244353;
      tmp2 = (long long)dp2[i][j] * dp[m][m - i] % 998244353;
      ans += (long long)tmp2 * j % 998244353;
      if (ans >= 998244353) ans -= 998244353;
    }
    pre = s;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &good[i]);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    sum += arr[i];
    if (good[i])
      sum_of_good += arr[i];
    else
      sum_of_bad += arr[i];
  }
  for (int i = max(1, sum - m); i <= sum + m; i++)
    inv[i - sum + M] = fastpower(i, 998244353 - 2);
  for (int i = sum_of_good; i <= sum_of_good + m; i++)
    inv2[i - sum_of_good] = fastpower(i, 998244353 - 2);
  for (int i = max(sum_of_bad - m, 1); i <= sum_of_bad; i++)
    inv3[sum_of_bad - i] = fastpower(i, 998244353 - 2);
  dp[0][0] = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= i; j++) {
      if (j)
        dp[i][j] =
            (long long)dp[i - 1][j - 1] * go_good(i - 1, j - 1) % 998244353;
      if (j < i)
        dp[i][j] += (long long)dp[i - 1][j] * go_bad(i - 1, j) % 998244353;
      if (dp[i][j] >= 998244353) dp[i][j] -= 998244353;
    }
  }
  int res;
  for (int i = 0; i < n; i++) {
    if (good[i])
      res = calc_good(arr[i]) + arr[i];
    else
      res = arr[i] - calc_bad(arr[i]);
    res = (((res % 998244353) + 998244353) % 998244353);
    printf("%d\n", res);
  }
  return 0;
}
