#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 1;
const int INF = 1e9;
const int MOD = 998244353;
long long fac[maxn];
void prep() {
  fac[0] = 1;
  for (int i = 1; i < maxn; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
  }
}
vector<int> g[maxn];
long long ans = 1;
long long sz[maxn];
int n;
void dfs(int v, int p) {
  int cnt_child = 0;
  sz[v] = 1;
  for (int to : g[v]) {
    if (to == p) {
      continue;
    }
    dfs(to, v);
    ++cnt_child;
    sz[v] += sz[to];
  }
  if (v == 1) {
    ans *= fac[cnt_child];
    ans %= MOD;
    ans *= n;
    ans %= MOD;
  } else {
    ans *= fac[cnt_child + 1];
    ans %= MOD;
  }
}
bool ok(int time, const vector<int> &hand, const std::vector<int> &heap) {
  vector<int> time_acquire(n + 1);
  set<int> s(hand.begin(), hand.end());
  vector<int> rev(n + 1);
  for (int i = 0; i < heap.size(); ++i) {
    rev[heap[i]] = i + 1;
  }
  for (int el = 1; el <= n; ++el) {
    if (s.count(el)) {
      time_acquire[el] = 0;
    } else {
      time_acquire[el] = rev[el];
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (time_acquire[i] > time - n + i - 1) {
      return false;
    }
  }
  return true;
}
long long a[1000];
long long w[1000];
long long dp[51][51][51];
long long pw(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = res * a % MOD;
    }
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  int m;
  cin >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> w[i];
  }
  long long sum = 0;
  long long sum_pos = 0;
  long long sum_neg = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i]) {
      sum_pos += w[i];
    } else {
      sum_neg += w[i];
    }
    sum += w[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      for (int e = 0; e <= m; ++e) {
        for (int x = 0; x <= m; ++x) {
          dp[j][e][x] = 0;
        }
      }
    }
    dp[0][0][0] = 1;
    bool is_positive = (a[i] == 1);
    for (int day = 0; day < m; ++day) {
      for (int clicks = 0; clicks <= day; ++clicks) {
        for (int positive = 0; positive <= day; ++positive) {
          long long overall_weight = sum + positive - (day - positive);
          if (is_positive) {
            add(dp[day + 1][clicks + 1][positive + 1],
                dp[day][clicks][positive] * (w[i] + clicks) % MOD *
                    pw(overall_weight, MOD - 2) % MOD);
            add(dp[day + 1][clicks][positive + 1],
                dp[day][clicks][positive] *
                    (sum_pos + positive - (w[i] + clicks)) % MOD *
                    pw(overall_weight, MOD - 2) % MOD);
            if (sum_neg - (day - positive) >= 0) {
              add(dp[day + 1][clicks][positive],
                  dp[day][clicks][positive] * (sum_neg - (day - positive)) %
                      MOD * pw(overall_weight, MOD - 2) % MOD);
            }
          } else {
            if (w[i] >= clicks) {
              add(dp[day + 1][clicks + 1][positive],
                  dp[day][clicks][positive] * (w[i] - clicks) % MOD *
                      pw(overall_weight, MOD - 2) % MOD);
            }
            if (sum_neg - (day - positive) - (w[i] - clicks) >= 0) {
              add(dp[day + 1][clicks][positive],
                  dp[day][clicks][positive] *
                      (sum_neg - (day - positive) - (w[i] - clicks)) % MOD *
                      pw(overall_weight, MOD - 2) % MOD);
            }
            add(dp[day + 1][clicks][positive + 1],
                dp[day][clicks][positive] * (sum_pos + positive) % MOD *
                    pw(overall_weight, MOD - 2) % MOD);
          }
        }
      }
    }
    long long ans = 0;
    if (is_positive) {
      for (int clicks = 0; clicks <= m; ++clicks) {
        for (int positive = 0; positive <= m; ++positive) {
          add(ans, (w[i] + clicks) * dp[m][clicks][positive] % MOD);
        }
      }
    } else {
      for (int clicks = 0; clicks <= m; ++clicks) {
        for (int positive = 0; positive <= m; ++positive) {
          add(ans, (w[i] - clicks) * dp[m][clicks][positive] % MOD);
        }
      }
    }
    cout << ans << "\n";
  }
}
