#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
std::vector<int> t, a, b, c, sol;
int n;
std::ifstream fin("curcubeu.in");
std::ofstream fout("curcubeu.out");
void Union(int x, int y)
{ t[x] = y; }
int Find(int x)
{
if (t[x] == x) return x;
return (t[x] = Find(t[x]));
}
int main()
{
fin >> n;
a.resize(n+1, 0); b.resize(n+1, 0);
c.resize(n+1, 0); t.resize(n+1, 1);
sol.resize(n+1, 0);
fin >> a[1] >> b[1] >> c[1];
for (long long i = 2; i < n; i++)
{
t[i] = i;
a[i] = (a[i-1] * i) % n;
b[i] = (b[i-1] * i) % n;
c[i] = (c[i-1] * i) % n;
}
t[0] = 0; t[n] = n;
for (int i = n - 1; i > 0; i--)
{
int st = std::min(a[i], b[i]), dr = std::max(a[i], b[i]);
for (int j = Find(st); j <= dr; j = Find(j))
{ sol[j] = c[i]; Union(j, Find(j+1)); }
}
for (int i = 1; i < n; i++)
fout << sol[i] << "\n";
return 0;
}