#include #include #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,fma,abm,mmx,avx,avx2") // url #define rep(i,a,b) for(int i=a;i=a;i--) #define all(x) (x).begin(),(x).end() #define pb(x) push_back(x); templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b=0.0)return (M_PI/2); else return (M_PI/2+M_PI); } else if(abs(y)<=eps){ if(x>=0.0)return 0.0; else return M_PI; } res=atan2(abs(y),abs(x)); if(x<=0&&y>=0)res=(M_PI-res); else if(x<=0&&y<=0)res+=(M_PI); else if(x>=0&&y<=0)res=(M_PI*2-res); return res; } ll gcd(ll a,ll b){ if(a==0||b==0)return a+b; ll r; r=a%b; if(r==0){ return b; } else{ return gcd(b,r); } } std::ostream &operator<<(std::ostream &dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(std::ios_base::badbit); } } return dest; } __int128 parse128(string &s) { __int128 ret = 0; for (int i = 0; i < s.length(); i++){ if ('0' <= s[i] && s[i] <= '9'){ ret = 10 * ret + s[i] - '0'; } } return ret; } using l3 = __int128; bool comp_arg(pair a,pair b){ if(a.second>=0&&b.second<0)return true; else if(a.second<0&&b.second>=0)return false; if(a.second>=0&&b.second>=0){ if(a.first>=0&&b.first<0)return true; } else{ if(a.first>=0&&b.first<0)return false; } ll det=a.first*b.second-a.second*b.first; if(det>0)return true; return false; } typedef pair P; using mint = modint; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,B;cin >> N >> B; mint::set_mod(B); int A[N];rep(i,0,N){ cin >> A[i]; A[i]--; } mint power2[N+1]; power2[0]=1;rep(i,1,N+1)power2[i]=power2[i-1]*2; vector ans; bool used[N];rep(i,0,N)used[i]=false; ans.pb(power2[N-1]); used[A[0]]=true; bool flag=false; int now=1; rep(i,0,N-1){ if(used[A[i+1]]){ ans.pb(power2[N]); } else{ used[A[i+1]]=true; now++; mint tmp=power2[now]-1; tmp*=power2[N-now]; ans.pb(tmp); } } for(auto x:ans){ cout << x.val() << endl; } }