#include <fstream>
using namespace std;
ifstream f("curcubeu.in");
ofstream g("curcubeu.out");
int n;
int st[1000001], dr[1000001], cul[1000001], c[1000001], urm[1000002];
int gaseste(int x)
{
int r = x, y;
while (urm[r] != r)
r = urm[r];
while (urm[x] != r)
{
y = urm[x];
urm[x] = r;
x = y;
}
return r;
}
int main()
{
int i, x;
long long A, B, C;
f >> n >> A >> B >> C;
for (i = 1; i < n; i++)
{
if (i > 1)
{
A = A * i % n;
B = B * i % n;
C = C * i % n;
}
if (A < B)
{
st[i] = A;
dr[i] = B;
}
else
{
st[i] = B;
dr[i] = A;
}
c[i] = C;
}
for (i = 1; i <= n; i++)
urm[i] = i;
for (i = n - 1; i >= 1; i--)
{
x = gaseste(st[i]);
while (x <= dr[i])
{
cul[x] = c[i];
urm[x] = x + 1;
x = gaseste(x + 1);
}
}
for (i = 1; i < n; i++)
g << cul[i] << "\n";
return 0;
}