#include <fstream>
using namespace std;
ifstream in("curcubeu.in");
ofstream out("curcubeu.out");
const int nmax = 1e6;
int n, a[nmax + 2], b[nmax + 2];
int color[nmax + 2];
int value[nmax + 2];
int main(){
in>>n>>a[1]>>b[1]>>value[1];
for(int i = 2; i <= n - 1; i++){
a[i] = (a[i - 1] * i) % n;
b[i] = (b[i - 1] * i) % n;
value[i] = (value[i - 1] * i) % n;
}
n--; ///op from a, b, value for [1, 2, ..., n - 1]
for(int i = 1; i <= n; i++){
if(a[i] > b[i]) swap(a[i], b[i]);
for(int it = a[i]; it <= b[i]; it++)
color[it] = value[i];
}
for(int i = 1; i <= n; i++)
out<<color[i]<<"\n";
return 0;
}