#include <bits/stdc++.h>   using namespace std;   const int P = 998244353, INF = 0x3f3f3f3f;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long qpow(long long a, long long n) {     long long r = 1 % P;     for (a %= P; n; a = a * a % P, n >>= 1)       if (n & 1) r = r * a % P;     return r;   }   long long inv(long long first) {     return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;   }   inline int rd() {     int first = 0;     char p = getchar();     while (p <  0  || p >  9 ) p = getchar();     while (p >=  0  && p <=  9 ) first = first * 10 + p -  0 , p = getchar();     return first;   }   const int N = 1e6 + 10;   int n, m, a[N], w[N], s1, s0;   int in[N];   int dp[55][55][55];   int solve(int a, int w) {     memset(dp, 0, sizeof dp);     dp[0][0][0] = 1;     int ans = 0;     if (a) {       for (int i = 1; i <= m + 1; ++i)         for (int j = 0; j <= i - 1; ++j)           for (int k = 0; k <= j; ++k)             if (dp[i - 1][j][k]) {               int &r = dp[i - 1][j][k];               int now = w + k, tot = s1 + s0 + j - (i - 1 - j),                   p = (long long)now * in[tot] % P;               dp[i][j + 1][k + 1] = (dp[i][j + 1][k + 1] + (long long)p * r) % P;               now = s1 - w + j - k, p = (long long)now * in[tot] % P;               dp[i][j + 1][k] = (dp[i][j + 1][k] + (long long)p * r) % P;               now = s0 - (i - 1 - j), p = (long long)now * in[tot] % P;               dp[i][j][k] = (dp[i][j][k] + (long long)p * r) % P;               if (i - 1 == m) ans = (ans + (long long)(w + k) * r) % P;             }       return ans;     }     for (int i = 1; i <= m + 1; ++i)       for (int j = 0; j <= i - 1; ++j)         for (int k = 0; k <= min(w, j); ++k)           if (dp[i - 1][j][k]) {             int &r = dp[i - 1][j][k];             int now = w - k, tot = s0 + s1 - j + (i - 1 - j),                 p = (long long)now * in[tot] % P;             dp[i][j + 1][k + 1] = (dp[i][j + 1][k + 1] + (long long)p * r) % P;             now = s1 + (i - 1 - j), p = (long long)now * in[tot] % P;             dp[i][j][k] = (dp[i][j][k] + (long long)p * r) % P;             now = s0 - w - j + k, p = (long long)now * in[tot] % P;             dp[i][j + 1][k] = (dp[i][j + 1][k] + (long long)p * r) % P;             if (i - 1 == m) ans = (ans + (long long)(w - k) * r) % P;           }     return ans;   }   int main() {     in[0] = 1;     for (int i = 1; i <= N - 1; ++i) in[i] = inv(i);     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , a + i);     for (int i = 1; i <= n; ++i) {       scanf( %d , w + i);       if (a[i])         s1 += w[i];       else         s0 += w[i];     }     for (int i = 1; i <= n; ++i) printf( %d n , solve(a[i], w[i]));   }   