#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
using namespace std;
vector<int> dsu_t;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int find(int x) {
int rad = x, y;
while(dsu_t[rad] != rad)
rad = dsu_t[rad];
while(x != rad) {
y = dsu_t[x];
dsu_t[x] = rad;
x = y;
}
return rad;
}
int main()
{
unsigned long long n, a, b, c; fin >> n >> a >> b >> c;
// cache a b c
vector<tuple<int,int,int>> cache(n);
for(int i = 1; i < n; ++i) {
a = (a * i) % n;
b = (b * i) % n;
c = (c * i) % n;
int left, right;
if(a < b) {
left = a; right = b;
} else {
left = b; right = a;
}
cache[i-1] = {left,right,c};
}
// build dsu where root = rightmost thats not colored
dsu_t.resize(n+1);
for(int i = 1; i <= n; ++i)
dsu_t[i] = i;
// reverse go through a b c
vector<int> colors(n);
for(int i = n-1; i >= 0; --i) {
tuple<int,int,int> t = cache[i];
int left = get<0>(t), right = get<1>(t), c = get<2>(t);
int node = find(left);
while(node <= right) {
colors[node] = c;
dsu_t[node] = node + 1;
node = find(node + 1);
}
}
for(int i = 1; i < n; ++i) {
fout << colors[i] << '\n';
}
return 0;
}