func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace FastIO {   const int L = (1 << 20);   char buf[L], *S, *T;   inline char getchar() {     if (S == T) {       T = (S = buf) + fread(buf, 1, L, stdin);       if (S == T) return EOF;     }     return *S++;   }   inline int read() {     int s = 0, f = 1;     char t = getchar();     while ( 0  > t || t >  9 ) {       if (t ==  - ) f = -1;       t = getchar();     }     while ( 0  <= t && t <=  9 ) {       s = (s << 1) + (s << 3) + t -  0 ;       t = getchar();     }     return s * f;   }   }  // namespace FastIO   using FastIO::read;   const int N = 55;   const int Mod = 998244353;   int dp[N][N][N * 2], sum, Sadd, Ssub;   int w[N], a[N], n, m;   int Inc(int x, int y) { return x + y >= Mod ? x + y - Mod : x + y; }   int Dec(int x, int y) { return x - y < 0 ? x - y + Mod : x - y; }   int Mul(int x, int y) { return (long long)x * y % Mod; }   int Fpow(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = Mul(ans, a);       b >>= 1;       a = Mul(a, a);     }     return ans;   }   int Inv(int x) { return Fpow(x, Mod - 2); }   void Dp(int c) {     memset(dp, 0, sizeof(dp));     dp[0][0][0] = 1;     for (int i = 0; i < m; i++) {       for (int k = 0; k <= i; k++) {         int now = (a[c] ? w[c] + k : w[c] - k);         if (now < 0) continue;         for (int d = 0; d <= i; d++) {           if (!dp[i][k][d]) continue;           int Dw = sum + d - (i - d);           Dw = Inv(Dw);           int Up_add = Sadd + d;           int Up_sub = Ssub - (i - d);           if (a[c]) {             dp[i + 1][k + 1][d + 1] =                 Inc(dp[i + 1][k + 1][d + 1], Mul(dp[i][k][d], Mul(now, Dw)));             dp[i + 1][k][d + 1] =                 Inc(dp[i + 1][k][d + 1], Mul(dp[i][k][d], Mul(Up_add - now, Dw)));             dp[i + 1][k][d] =                 Inc(dp[i + 1][k][d], Mul(dp[i][k][d], Mul(Up_sub, Dw)));           } else {             dp[i + 1][k + 1][d] =                 Inc(dp[i + 1][k + 1][d], Mul(dp[i][k][d], Mul(now, Dw)));             dp[i + 1][k][d + 1] =                 Inc(dp[i + 1][k][d + 1], Mul(dp[i][k][d], Mul(Up_add, Dw)));             dp[i + 1][k][d] =                 Inc(dp[i + 1][k][d], Mul(dp[i][k][d], Mul(Up_sub - now, Dw)));           }         }       }     }     int Ans = 0;     for (int k = 0; k <= m; k++) {       int now = (a[c] ? w[c] + k : w[c] - k);       if (now < 0) continue;       for (int d = 0; d <= m; d++) {         Ans = Inc(Ans, Mul(now, dp[m][k][d]));       }     }     cout << Ans <<   n ;   }   int main() {     n = read();     m = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= n; i++) {       w[i] = read();       if (a[i])         Sadd += w[i];       else         Ssub += w[i];       sum += w[i];     }     for (int i = 1; i <= n; i++) Dp(i);     return 0;   }   