#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> parinte;
void creeaza_multime(int v) {
parinte[v] = v;}
int gaseste(int v) {
if (v == parinte[v])
return v;
return parinte[v] = gaseste(parinte[v]);
}
void uneste(int a, int b) {
a = gaseste(a);
b = gaseste(b);
if (a != b)
parinte[b] = a;}
int main() {
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int N;
long long a1, b1, c1;
fin>>N>>a1>>b1>>c1;
vector<int> A(N), B(N), C(N);
A[1] = a1;
B[1] = b1;
C[1] = c1;
for (int 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;
}
parinte.resize(N + 1);
for (int v = 0; v <= N; v++)
creeaza_multime(v);
vector<int> culoare(N, 0);
for (int i = N - 1; i >= 1; i--) {
int st = max(1, min(A[i], B[i]));
int dr = max(A[i], B[i]);
int x = gaseste(st);
while (x <= dr) {
culoare[x] = C[i];
uneste(x + 1, x);
x = gaseste(x);
}
}
for (int i = 1; i <= N - 1; i++)
fout << culoare[i] << '\n';
return 0;
}