#include <bits/stdc++.h>
using namespace std;
const string FILENAME = "curcubeu";
#ifndef zz
ifstream f(FILENAME + ".in");
ofstream g(FILENAME + ".out");
#define cin f
#define cout g
#endif
int n,a,b,c;
pair<int, int> t[1000001]; // (par, col)
int sz[1000001];
pair<int,int> find_set(int v) {
if(v == t[v].first) return t[v];
return t[v] = find_set(t[v].first);
}
void make_set(int v, int c) {
t[v].first = v;
t[v].second = c;
sz[v] = 1;
}
void union_sets(pair<int,int> a, pair<int,int> b) {
a = find_set(a.first);
b = find_set(b.first);
if(a != b) {
if(sz[a.first] < sz[b.first]) {
swap(a,b);
}
t[b.first] = a;
sz[a.first] += sz[b.first];
}
}
int main() {
cin >> n >> a >> b >> c;
int A = a;
int B = b;
if(A > B) swap(A, B);
make_set(A ,c);
for(int i=A+1;i<=B;++i) union_sets({A,c},{i,c});
for(int i=2;i<n;++i) {
a = (a * i) % n;
b = (b * i) % n;
c = (c * i) % n;
A = a;
B = b;
if(A > B) swap(A,B);
make_set(A, c);
for(int i=A+1;i<=B;++i) union_sets({A,c},{i,c});
}
for(int i=1;i<n;++i) {
if(!sz[i]) cout << 0 << '\n';
else cout << t[i].second << '\n';
}
}