#include <bits/stdc++.h>
using namespace std;
const int MAXIM = 1000005;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int A[MAXIM];
int B[MAXIM];
int C[MAXIM];
int nxt[MAXIM];
int col[MAXIM];
int findNext(int x) {
int root = x;
while (nxt[root] != root) {
root = nxt[root];
}
while (nxt[x] != root) {
const int p = nxt[x];
nxt[x] = root;
x = p;
}
return root;
}
int main() {
int n;
fin >> n >> A[1] >> B[1] >> C[1];
for (int i = 2; i < n; i++) {
A[i] = static_cast<int>((1LL * A[i - 1] * i) % n);
B[i] = static_cast<int>((1LL * B[i - 1] * i) % n);
C[i] = static_cast<int>((1LL * C[i - 1] * i) % n);
}
for (int i = 1; i <= n; i++) {
nxt[i] = i;
}
for (int i = n - 1; i >= 1; i--) {
const int l = min(A[i], B[i]);
const int r = max(A[i], B[i]);
for (int x = findNext(l); x <= r; x = findNext(x)) {
col[x] = C[i];
nxt[x] = findNext(x + 1);
}
}
for (int i = 1; i < n; i++) {
fout << col[i] << '\n';
}
}