#include<iostream>
#include<stack>
#include<vector>
#include<tuple>
#include<fstream>
using namespace std;
ifstream file_in("curcubeu.in");
ofstream file_out("curcubeu.out");
stack<tuple<int, int ,int>> stiva;
vector<int> nextFree;
vector<int> rez;
int N, A, B, C;
int find(int x){
if (x == nextFree[x]){
return x;
}
nextFree[x] = find(nextFree[x]);
return nextFree[x];
}
int main(){
file_in >> N >> A >> B >> C;
nextFree.resize(N+1, 0);
rez.resize(N+1, 0);
for (int i=1; i<=N; i++ ){
nextFree[i] = i;
}
stiva.push({min(A, B), max(A, B), C});
for (int i=2; i<=N-1; i++){
A = (A * i) % N;
B = (B * i) % N;
C = (C * i) % N;
if (B > A) {
stiva.push({A, B, C});
} else {
stiva.push({B, A, C});
}
}
while (!stiva.empty()){
A = get<0>(stiva.top());
B = get<1>(stiva.top());
C = get<2>(stiva.top());
stiva.pop();
int i = A;
while (i <= B){
if (i == find(i)){
rez[i] = C;
nextFree[i] = find(i+1);
}
i = nextFree[i];
}
}
for (int i=1; i<=N-1; i++){
file_out << rez[i] << '\n';
}
return 0;
}