#include #include #include #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native") using namespace std; using namespace __gnu_pbds; template using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>; //~ while (clock()<=69*CLOCKS_PER_SEC) #define ll long long #define ld long double #define pi pair #define pd pair #define ft first #define sd second #define st first #define nd second #define mp make_pair #define pb push_back #define eb emplace_back #define FOR(i,a,b) for(int i=(a); i<=(b);i++) #define F(i,a,b) FOR(i,(a),(b)-1) #define REV(i,a,b) for(int i=(a); i>=(b);i--) #define VI vector #define VPI vector #define VPD vector #define PI 3.14159265 #define all(x) (x).begin(), (x).end() #define sz(a) (int)((a).size()) //#define int long long template void _dbg(const char *sdbg, TH h){cerr< void _dbg(const char *sdbg, TH h, TA... a) { while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<> n >> k; VI w(n + 1); FOR(i, 1, n) cin >> w[i]; pre[0][0][0] = 1; suf[n + 1][0][0] = 1; FOR(i, 1, n) { FOR(j, 0, k) { pre[i][0][0] = 1; F(l, 1, n) { if (j - w[i] >= 0) (pre[i][j][l] += pre[i - 1][j - w[i]][l - 1]) %= MOD; (pre[i][j][l] += pre[i - 1][j][l]) % MOD; } } } REV(i, n, 1) { FOR(j, 0, k) { suf[i][0][0] = 1; F(l, 1, n) { if (j - w[i] >= 0) (suf[i][j][l] += suf[i + 1][j - w[i]][l - 1]) %= MOD; (suf[i][j][l] += suf[i + 1][j][l]) %= MOD; } } } FOR(i, 1, n) { if (i - 1 >= n - i) { F(l, 0, n) { FOR(j, 0, k) dp[j][l] = pre[i - 1][j][l]; } FOR(el, i + 1, n) { REV(l, n - 1, 1) { FOR(j, w[el], k) { (dp[j][l] += dp[j - w[el]][l - 1]) %= MOD; } } } } else { F(l, 0, n) { FOR(j, 0, k) dp[j][l] = suf[i + 1][j][l]; } FOR(el, 1, i - 1) { REV(l, n - 1, 1) { FOR(j, w[el], k) { (dp[j][l] += dp[j - w[el]][l - 1]) %= MOD; } } } } F(l, 1, n) { int res = 0; FOR(j, k - w[i] + 1, k) { (res += dp[j][l]) %= MOD; } cout << res << " "; } cout << "\n"; } } int32_t main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cerr.tie(0); cout<>test; F(_test, 0, test){ //cout<<"Case #"<<_test + 1<<": "; solve(); // if(_test == 1) // return 0; } return 0; } /* 3 B B.. ... ... 3 B BBB BBB BBB 3 K KKK KKK KKK */