#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
vector<int> nxt;
int find_next(int u) {
int root = u;
while (nxt[root] != root)
root = nxt[root];
while (nxt[u] != root) {
int temp = nxt[u];
nxt[u] = root;
u = temp;
}
return root;
}
int main() {
int n;
fin >> n;
vector<int> a(n), b(n), c(n);
fin >> a[1] >> b[1] >> c[1];
for (long long i = 2; i < n; i++) {
a[i] = (a[i - 1] * i) % n;
b[i] = (b[i - 1] * i) % n;
c[i] = (c[i - 1] * i) % n;
}
nxt.resize(n + 1);
for (int i = 1; i <= n; ++i)
nxt[i] = i;
vector<int> color(n, 0);
for (int i = n - 1; i >= 1; --i) {
int left = min(a[i], b[i]);
int right = max(a[i], b[i]);
int pos = find_next(left);
while (pos <= right) {
color[pos] = c[i];
nxt[pos] = pos + 1;
pos = find_next(pos);
}
}
for (int i = 1; i < n; ++i) {
fout << color[i] << "\n";
}
return 0;
}