#include <algorithm>
#include <fstream>
using namespace std;
int n, a[1000001], b[1000001], c[1000001], nxt[1000002], col[1000001];
int f(int x) {
while (nxt[x] != x) {
nxt[x] = nxt[nxt[x]];
x = nxt[x];
}
return x;
}
int main() {
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
long long A, B, C;
fin >> n >> A >> B >> C;
for (int i = 1; i < n; i++) {
if (i > 1) {
A = A * i % n;
B = B * i % n;
C = C * i % n;
}
a[i] = min(A, B);
b[i] = max(A, B);
c[i] = C;
}
for (int i = 1; i <= n; i++)
nxt[i] = i;
for (int i = n - 1; i >= 1; i--) {
int x = f(a[i]);
while (x <= b[i]) {
col[x] = c[i];
nxt[x] = x + 1;
x = f(x + 1);
}
}
for (int i = 1; i < n; i++)
fout << col[i] << "\n";
}