#include #include #include #include #include #include #include using namespace std; const int NMAX = 100; const int AMAX = 100000; vector A; int N, M, C, sumA; long long powmod(long long a, long long n, long long p) { if (n == 0) return 1; return powmod(a * a % p, n / 2, p) * (n % 2 == 1 ? a : 1) % p; } long long inv(long long a, long long p) { return powmod(a, p - 2, p); } bool is_prime(long long a) { for (long long div = 2; div * div <= a; ++div) if (a % div == 0) return false; return true; } long long primitive_root(long long p) { vector div; for (long long i = 2; i * i <= p - 1; ++i) { if ((p - 1) % i == 0) { div.push_back(i); div.push_back((p - 1) / i); } } for (long long i = 1; i < p - 1; ++i) { bool ok = true; for (long long d : div) { ok &= powmod(i, d, p) != 1; } if (ok) return i; } } long long garner(vector& a, vector& mods, long long m) { int n = a.size(); vector b; auto gen_base = [&mods](int mod) { vector base{ 1 }; for (int j = 0; j < mods.size(); ++j) { base.push_back((int)(1LL * base.back() * mods[j] % mod)); } return base; }; auto f = [&b](vector base, int mod) { long long x = 0; for (int j = 0; j < b.size(); ++j) { x = (x + 1LL * b[j] * base[j]) % mod; } return (int) x; }; for (int i = 0; i < n; ++i) { auto base = gen_base(mods[i]); b.push_back((int) (inv(base[i], mods[i]) * (-f(base, mods[i]) + a[i]) % mods[i])); if (b[i] < 0) b[i] += mods[i]; } return f(gen_base(m), m); } void solve(long long mod, vector& ans) { long long g = primitive_root(mod); long long r = powmod(g, (mod - 1) / C, mod); for (int i = 0; i < C; ++i) { long long zeta = powmod(r, i, mod); vector f(ans.size()); f[0] = 1; for (int a : A) { for (int j = ans.size() - 1 - a; j >= 0; --j) { f[j + a] += zeta * f[j] % mod; f[j + a] %= mod; } } for (int j = 0; j < ans.size(); ++j) ans[j] = (ans[j] + f[j]) % mod; } ans[0] -= C; for (int i = 0; i < ans.size(); ++i) ans[i] = (int) (1LL * inv(C, mod) % mod * ans[i] % mod); } int main() { cin >> N >> M >> C; A.resize(N); for (int i = 0; i < N; ++i) cin >> A[i]; for (int a : A) sumA += a; bool reversed = 2 * C < N; if (reversed) C = N - C; vector mods; for (int m = 1000'000'000 / C * C + 1; mods.size() != 3; m += C) { if (is_prime(m)) mods.push_back(m); } vector> x(4, vector(sumA + 1)); for (int i = 0; i < mods.size(); ++i) { solve(mods[i], x[i]); } vector ans(sumA + 1); for (int i = 0; i <= sumA; ++i) { vector a; for (int j = 0; j < mods.size(); ++j) a.push_back(x[j][i]); ans[i] = garner(a, mods, M); } if (reversed) { for (int i = 0; i <= C / 2; ++i) { swap(ans[i], ans[C - i]); } } if (N == 2 * C) ans[sumA] -= 1; for (int i = 1; i <= sumA; ++i) cout << ans[i] << (i == sumA ? "\n" : " "); }