#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int A[1000005], B[1000005], C[1000005], nx[1000005], col[1000005];
int root(int x) {
while (nx[x] != x) {
nx[x] = nx[nx[x]];
x = nx[x];
}
return x;
}
int main() {
int n;
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++) nx[i] = i;
for (int i = n - 1; i >= 1; i--) {
int l = min(A[i], B[i]);
int r = max(A[i], B[i]);
for (int j = root(l); j <= r; j = root(j + 1)) {
col[j] = C[i];
nx[j] = j + 1;
}
}
for (int i = 1; i < n; i++) fout << col[i] << '\n';
}