#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> nxt;
// prima casuta nevopsita >= x
int urm(int x) {
return nxt[x] == x ? x : nxt[x] = urm(nxt[x]);
}
int main() {
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
long long a, b, c;
fin >> n >> a >> b >> c;
vector<int> A(n), B(n), C(n), col(n + 1, 0);
A[1] = a;
B[1] = b;
C[1] = c;
for (int i = 2; i < n; 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;
}
nxt.resize(n + 1);
iota(nxt.begin(), nxt.end(), 0);
// invers: ultima vopsire castiga
for (int i = n - 1; i >= 1; i--) {
int l = min(A[i], B[i]), r = max(A[i], B[i]);
for (int x = urm(l); x <= r; x = urm(x)) {
col[x] = C[i];
nxt[x] = x + 1;
}
}
for (int i = 1; i < n; i++) {
fout << col[i] << "\n";
}
}