include <bits/stdc++.h>

using namespace std;

int main()
{
int N,P;
cin>>N>>P;
vector<int> arr(N+2,1);
vector<long long=""> rev(N+2,1);
vector<long long=""> res(N+2,1);
for(int i=1;i<=N;i++)
{
cin>>arr[i];
res[i]=res[i-1]arr[i-1]%P;
}
for(int j=N;j>0;j--)
{
rev[j]=rev[j+1]
arr[j+1]%P;
}
for(int i=1;i<=N;i++)
cout<<(rev[i]*res[i])%P<<" ";
return 0;
}</long></long></int>