#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int n;
vector<int> a, b, c;
vector<int> tata, culoare;
int gaseste(int x) {
if (tata[x] == x)
return x;
return tata[x] = gaseste(tata[x]);
}
int main() {
fin >> n;
a.resize(n);
b.resize(n);
c.resize(n);
tata.resize(n + 1);
culoare.assign(n, 0);
fin >> 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++)
tata[i] = i;
for (int i = n - 1; i >= 1; i--) {
int st = min(a[i], b[i]);
int dr = max(a[i], b[i]);
int x = gaseste(st);
while (x <= dr) {
culoare[x] = c[i];
tata[x] = gaseste(x + 1);
x = gaseste(x);
}
}
for (int i = 1; i < n; i++)
fout << culoare[i] << '\n';
return 0;
}