#include <bits/stdc++.h>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int n;
int a,b,c;
int tt[1000005];
int root(int i)
{
if(tt[i]!=i)
tt[i]=root(tt[i]);
return tt[i];
}
int ans[1000005];
int main()
{
fin>>n>>a>>b>>c;
for(int i=1; i<n; i++)
tt[i]=i;
int i=1;
while(i<n)
{
int l=min(a,b),r=max(a,b);
vector <int> aux;
int j=l;
while(j<=r)
{
ans[j]=c;
if(tt[j]==j)
{
aux.push_back(j);
j++;
}
else
{
j=root(j);
}
}
for(auto it:aux)
tt[it]=r+1;
i++;
a=1LL*a*i%n;
b=1LL*b*i%n;
c=1LL*c*i%n;
}
for(int i=1; i<n; i++)
fout<<ans[i]<<"\n";
return 0;
}