#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
const int NMAX = 1000005;
int a[NMAX], b[NMAX], c[NMAX];
int nxt[NMAX], col[NMAX];
// prima pozitie libera >= x
int gaseste(int x) {
if (nxt[x] == x)
return x;
nxt[x] = gaseste(nxt[x]);
return nxt[x];
}
int main() {
int n;
fin >> n >> a[1] >> b[1] >> c[1];
// generam operatiile
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;
}
// initial toate pozitiile sunt libere
for (int i = 1; i <= n; i++) {
nxt[i] = i;
}
// luam operatiile in ord inversa
for (int i = n - 1; i >= 1; i--) {
int st = min(a[i], b[i]);
int dr = max(a[i], b[i]);
if (st == 0) st = 1;
// coloram si sarim peste cele deja colorate
for (int j = gaseste(st); j <= dr; j = gaseste(j)) {
col[j] = c[i];
nxt[j] = gaseste(j + 1);
}
}
// afisare
for (int i = 1; i < n; i++) {
fout << col[i] << "\n";
}
return 0;
}