#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int n;
int a[100005], b[100005], c[100005];
int urm[1000005], culoare[1000005];
int gaseste(int x){
int r = x;
while(urm[r] != r) r = urm[r];
while(urm[x] != r){
int aux = urm[x];
urm[x] = r;
x= aux;
}
return r;
}
int main(){
fin >> n >> 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;
}
for(int i = 1; i <= n; i++) urm[i] = i;
for(int i = n - 1; i >= 1; i--){
int st = min(a[i], b[i]);
int dr = max(a[i], b[i]);
int p = gaseste(st);
while(p <= dr){
culoare[p] = c[i];
urm[p] = p + 1;
p = gaseste(p + 1);
}
}
for(int i = 1; i < n; i++){
fout << culoare[i] << endl;
}
}