#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int Read() {
  char c;
  c = getchar();
  int tsqua = 0;
  while (c != ' ' && c != '\n') {
    tsqua = (((tsqua << 1) << 1) << 1) + (tsqua << 1) + (int)(c - '0');
    c = getchar();
  }
  return tsqua;
}
const long long mod = 998244353;
long long Change(long long x) { return x % mod; }
long long GetSum(long long x, long long y) { return Change(x + y); }
long long GetDif(long long x, long long y) {
  return Change(Change(x - y) + mod);
}
long long GetTim(long long x, long long y) { return Change(x * y); }
int n, m;
int like[2000010];
int weight[2000010];
long long DP1[3010][3010], DP2[3010][3010];
long long num[10010];
long long INF;
long long GetPow(long long inf, long long MOD_MINUS_2, long long MOD) {
  if (MOD_MINUS_2 == 0) return 1ll;
  long long tmp = GetPow(inf, MOD_MINUS_2 / 2, MOD);
  tmp %= MOD;
  tmp = (tmp * tmp) % MOD;
  if (MOD_MINUS_2 % 2 == 1) tmp = (tmp * inf) % MOD;
  return tmp;
}
long long cnt_like, cnt_dislike;
void Init() {
  INF = cnt_like + cnt_dislike + 5000;
  for (int i = 0; i < 10000; i++) {
    if (i > INF) break;
    num[i] = GetPow(INF - i, mod - 2, mod);
  }
}
long long GetNum(long long x) { return num[INF - x]; }
int main(int argc, char const *argv[]) {
  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];
  for (int i = 1; i <= n; i++) {
    if (like[i])
      cnt_like += weight[i];
    else
      cnt_dislike += weight[i];
  }
  Init();
  for (int i = 0; i <= m; i++) {
    if (m - i > cnt_dislike) continue;
    DP1[i][m - i] = DP2[i][m - i] = 1;
  }
  for (int i = m - 1; i >= 0; i--)
    for (int j = min(cnt_dislike, m - i - 1ll); j >= 0; j--)
      DP1[i][j] = GetSum(
          GetTim(GetTim(DP1[i + 1][j],
                        GetNum(cnt_like + i + max(cnt_dislike - j, 0ll))),
                 2ll),
          GetSum(
              GetTim(cnt_like + i - 1,
                     GetTim(DP1[i + 1][j],
                            GetNum(cnt_like + i + max(cnt_dislike - j, 0ll)))),
              GetTim(
                  max(cnt_dislike - j, 0ll),
                  GetTim(DP1[i][j + 1],
                         GetNum(cnt_like + i + max(cnt_dislike - j, 0ll)))))),
      DP2[i][j] = GetSum(
          GetTim(max(cnt_dislike - j - 1, 0ll),
                 GetTim(DP2[i][j + 1],
                        GetNum(cnt_like + i + max(cnt_dislike - j, 0ll)))),
          GetTim(cnt_like + i,
                 GetTim(DP2[i + 1][j],
                        GetNum(cnt_like + i + max(cnt_dislike - j, 0ll)))));
  for (int i = 1; i <= n; i++)
    cout << (like[i] ? GetTim(weight[i], DP1[0][0])
                     : GetTim(weight[i], DP2[0][0]))
         << endl;
  return 0;
}
