#include <bits/stdc++.h>
using namespace std;
int findRoot( vector<int>& tata, int x ) {
int rad, y;
rad = x;
while ( tata[rad] != rad )
rad = tata[rad];
while ( tata[x] != x ) {
y = tata[x];
tata[x] = rad;
x = y;
}
return rad;
}
int main() {
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int n, i, st, dr, p;
long long a, b, c;
vector<long long> A, B, C;
vector<int> ans, tata;
fin >> n >> a >> b >> c;
A.resize(n);
B.resize(n);
C.resize(n);
ans.assign(n, 0);
tata.resize(n + 1);
A[1] = a;
B[1] = b;
C[1] = c;
for ( i = 2; i < n; i++ ) {
A[i] = A[i - 1] * i % n;
B[i] = B[i - 1] * i % n;
C[i] = C[i - 1] * i % n;
}
for ( i = 1; i <= n; i++ )
tata[i] = i;
for ( i = n - 1; i >= 1; i-- ) {
st = min(A[i], B[i]);
dr = max(A[i], B[i]);
p = findRoot(tata, st);
while ( p <= dr ) {
ans[p] = C[i];
tata[p] = findRoot(tata, p + 1);
p = findRoot(tata, p);
}
}
for ( i = 1; i < n; i++ )
fout << ans[i] << '\n';
return 0;
}