#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
const int nax = 102;
ll dp[nax][nax * nax * nax];
 
int mod;
 
int main()
{
    int n,k; cin>>n>>k; cin>>mod;
    dp[0][0] = 1;
    for(int i=1;i<=n;i++)
    {
        for(int c=0;c<nax * nax * nax / 2;c++)
        {
            if(c < i)
            {
                dp[i][c] = dp[i - 1][c];
            }
            else
            {
                dp[i][c] = dp[i][c - i];
                dp[i][c] += dp[i - 1][c];
                int taken = (c + i) / i;
                if(taken > k + 1) dp[i][c] -= dp[i - 1][c - i * (k + 1)];
                dp[i][c] += mod;
                dp[i][c] %= mod;
            }
        }
    }
 
    for(int x=1;x<=n;x++)
    {
        ll ways = k + 1;
 
        int ans = 0;
        for(int j=1;j<nax * nax * nax / 2;j++)
        {
            int v1 = x - 1;
            int v2 = n - x;
            ll cur = ways * dp[v1][j];
            cur %= mod;
            cur *= dp[v2][j];
            cur %= mod;
            ans += cur;
            if(ans >= mod) ans -= mod;
        }
        ans += k;
        cout<<ans<<"\n";
    }
 
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;//1152921504606846976
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
struct unionfind{
    vector<int> par,rank;
    unionfind(int x){
        par.resize(x);
        rank.resize(x);
        for(int i=0; i<x; i++)par[i]=-1,rank[i]=0;
    }
    int root(int x){
        if(par[x]<0)return x;
        return par[x]=root(par[x]);
    }
    void uni(int x,int y){
        x=root(x),y=root(y);
        if(x==y)return;
        if(rank[x]<rank[y]){par[y]+=par[x];par[x]=y;}
        else{
            par[x]+=par[y];par[y]=x;
            if(rank[x]==rank[y])rank[x]++;
        }
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    unionfind uf(n);
    rep(i,n){
        ll f;cin>>f;
        uf.uni(i, f-1);
    }
    set<ll> m;
    rep(i,n)m.insert(uf.root(i));
    cout<<(mint(2).pow(m.size())-1).x<<endl;


    return 0;
}