#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("curcubeu.in");
ofstream g("curcubeu.out");
const int NMAX = 1000005;
int a[NMAX];
int b[NMAX];
int c[NMAX];
int tata[NMAX];
int culoare[NMAX];
int find_set(int x)
{
if (tata[x] == x)
return x;
return tata[x] = find_set(tata[x]);
}
int main()
{
int n,i;
f >> n >> a[1] >> b[1] >> c[1];
for(i = 2; i <= n - 1; i++)
{
a[i] = (1LL * a[i - 1] * i) % n;
b[i] = (1LL * b[i - 1] * i) % n;
c[i] = (1LL * c[i - 1] * i) % n;
}
for(i = 1; i <= n; i++)
tata[i] = i;
for(i = n - 1; i >= 1; i--)
{
int st = min(a[i], b[i]);
int dr = max(a[i], b[i]);
int poz = find_set(st);
while (poz <= dr)
{
culoare[poz] = c[i];
tata[poz] = find_set(poz + 1);
poz = tata[poz];
}
}
for(i = 1; i <= n - 1; i++)
g << culoare[i] << endl;
return 0;
}