#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int a[1000005], b[1000005], c[1000005];
int nxt[1000005], color[1000005];
int find_next(int x) {
int root = x;
while (nxt[root] != root) {
root = nxt[root];
}
while (x != root) {
int temp = nxt[x];
nxt[x] = root;
x = temp;
}
return root;
}
int main() {
int n, ca, cb, cc;
fin >> n >> ca >> cb >> cc;
for (int i = 1; i < n; ++i) {
a[i] = ca;
b[i] = cb;
c[i] = cc;
ca = (1LL * ca * (i + 1)) % n;
cb = (1LL * cb * (i + 1)) % n;
cc = (1LL * cc * (i + 1)) % n;
}
for (int i = 1; i <= n; ++i) {
nxt[i] = i;
}
for (int i = n - 1; i >= 1; --i) {
int st = min(a[i], b[i]);
int dr = max(a[i], b[i]);
for (int pos = find_next(st); pos <= dr; pos = find_next(pos)) {
color[pos] = c[i];
nxt[pos] = find_next(pos + 1);
}
}
for (int i = 1; i < n; ++i) {
fout << color[i] << '\n';
}
return 0;
}