#include <fstream>
#include <algorithm>
std::ifstream fin("curcubeu.in");
std::ofstream fout("curcubeu.out");
const int NMAX = 1000005;
int n;
int a[NMAX], b[NMAX], c[NMAX];
int color[NMAX];
int nxt[NMAX];
int find(int x) {
int root = x;
while (nxt[root] != root)
root = nxt[root];
while (nxt[x] != root) {
int y = nxt[x];
nxt[x] = root;
x = y;
}
return root;
}
int main() {
fin >> n >> a[1] >> b[1] >> c[1];
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;
}
for (int i = 1; i <= n; i++)
nxt[i] = i;
for (int i = n - 1; i >= 1; i--) {
int lo = std::min(a[i], b[i]);
int hi = std::max(a[i], b[i]);
for (int j = find(lo); j <= hi; j = find(j)) {
color[j] = c[i];
nxt[j] = j + 1;
}
}
for (int i = 1; i < n; i++)
fout << color[i] << '\n';
return 0;
}