#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
pair<int, int> v[200005];
int dp[2][2][3005][3005], ans[2];
int liked, disliked;
int exp(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = ((long long)r * a) % MOD;
    b /= 2;
    a = ((long long)a * a) % MOD;
  }
  return r;
}
int inv(int n) { return exp(n, MOD - 2); }
inline void add(int& a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
inline int mul(int a, int b) { return ((long long)a * b) % MOD; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &v[i].first);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i].second);
    liked += v[i].first * v[i].second;
    disliked += (!v[i].first) * v[i].second;
  }
  dp[1][1][0][0] = dp[0][1][0][0] = 1;
  for (int i = 0; i < m; i++)
    for (int j = 0; j <= i; j++) {
      int k = i - j;
      if (liked + j + disliked - k <= 0) continue;
      int aux = inv(liked + j + disliked - k);
      add(dp[1][1][i + 1][j + 1],
          mul(mul(dp[1][1][i][j], (liked + j + 1)), aux));
      add(dp[1][1][i + 1][j], mul(mul(dp[1][1][i][j], (disliked - k)), aux));
    }
  for (int i = 0; i < m; i++)
    for (int j = 0; j <= i; j++) {
      int k = i - j;
      if (liked + j + disliked - k <= 0) continue;
      int aux = inv(liked + j + disliked - k);
      add(dp[0][1][i + 1][j],
          mul(mul(dp[0][1][i][j], (disliked - k - 1)), aux));
      add(dp[0][1][i + 1][j + 1], mul(mul(dp[0][1][i][j], (liked + j)), aux));
      add(dp[0][0][i + 1][j], mul(mul(dp[0][1][i][j], 1), aux));
    }
  for (int i = 0; i <= 1; i++)
    for (int w = 0; w <= 1; w++)
      for (int j = 0; j <= m; j++) add(ans[i], mul(w, dp[i][w][m][j]));
  for (int cur = 0; cur < n; cur++)
    printf("%d\n", mul(ans[v[cur].first], v[cur].second));
  return 0;
}
