#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <stack>
#include <algorithm>
#include <fstream>
#include <set>
using namespace std;
struct Edge {
int to;
int cost;
};
struct Node {
int n = -1;
vector<Edge> Adj;
bool IsAdjTo(int v) {
for (auto& i : Adj) {
if (i.to == v) {
return true;
}
}
return false;
}
};
struct Graph {
private:
bool Oriented;
bool Weighted;
vector<Node> Nodes;
int edgeCount = 0;
public:
Graph(bool _Oriented = true, bool _Weighted = false) {
Oriented = _Oriented;
Weighted = _Weighted;
}
void SetOriented(bool _Oriented) {
Oriented = _Oriented;
}
void SetNodeCount(int n) {
Nodes.resize(n);
for (int i = 0; i < n; i++) {
Nodes[i].n = i;
}
}
int GetNodeCount() {
return Nodes.size();
}
Node& operator[] (int i) {
return Nodes[i];
}
void AddEdge(int u, int v, int w = 1) {
Nodes[u].Adj.push_back({.to = v, .cost = w});
if (!Oriented)
Nodes[v].Adj.push_back({.to = u, .cost = w});
edgeCount++;
}
vector<Edge>& GetEdges(int u) {
return Nodes[u].Adj;
}
int GetEdgeCount() const {
return edgeCount;
}
};
#define in fin
#define out fout
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
void ReadMEdges(Graph &G, int M) {
while (M--) {
int u, v;
in >> u >> v;
G.AddEdge(u-1, v-1);
}
}
void ReadGraph(Graph &G, int N, int M) {
G.SetNodeCount(N);
ReadMEdges(G, M);
}
int charToId(char c) {
if (c >= 'a' && c <= 'z')
return c - 'a';
return c - 'A' + 26;
}
char idToChar(int id) {
if (id < 26)
return 'a' + id;
return 'A' + id - 26;
}
int findRoot(int x, vector<int>& tata) {
int root = x;
while (tata[root] != root) {
root = tata[root];
}
while (tata[x] != root) {
int next = tata[x];
tata[x] = root;
x = next;
}
return root;
}
void curcubeu() {
int N;
if (!(in >> N)) return;
vector<int> A(N), B(N), C(N);
in >> 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;
}
vector<int> tata(N + 1);
for (int i = 0; i <= N; i++) {
tata[i] = i;
}
vector<int> color(N + 1, 0);
for (int i = N - 1; i >= 1; i--) {
int st = min(A[i], B[i]);
int dr = max(A[i], B[i]);
int pos = findRoot(st, tata);
while (pos <= dr) {
color[pos] = C[i];
tata[pos] = findRoot(pos + 1, tata);
pos = tata[pos];
}
}
for (int i = 1; i < N; i++) {
out << color[i] << "\n";
}
}
int main() {
curcubeu();
}