#include <bits/stdc++.h>
using namespace std;
int const MX = 40000000;
int n;
long long m, p;
bool vis[MX];
vector<long long> v;
inline void ad(long long &x, long long y, long long md) {
  if ((x += y) >= md) x -= md;
}
inline long long add(long long x, long long y, long long md) {
  ad(x, y, md);
  return x;
}
void no() {
  printf("-1\n");
  exit(0);
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void fn(vector<long long> const &v) {
  if (v.size() < n) no();
  printf("%lld", v[0]);
  for (int i = 1; i < (int)(v.size()); ++i) printf(" %lld", v[i]);
  printf("\n");
  exit(0);
}
long long ml(long long a, long long b, long long md) {
  long long an = 0;
  if (b > a) swap(a, b);
  while (b) {
    if (b & 1) ad(an, a, md);
    ad(a, a, md);
    b >>= 1;
  }
  return an;
}
long long pw(long long a, long long p, long long md) {
  long long an = 1;
  while (p) {
    if (p & 1) an = ml(an, a, md);
    a = ml(a, a, md);
    p >>= 1;
  }
  return an;
}
bool isp(long long x) {
  if (x == 2) return true;
  if (!(x & 1)) return false;
  long long p = x - 1;
  while (!(p & 1)) p >>= 1;
  for (int i = 0; i < (int)(10); ++i) {
    int a = rand() % (x - 2) + 2;
    long long z = pw(a, p, x), pp = p;
    if (z == x - 1 || z == 1) continue;
    bool ok = false;
    while (pp << 1 < x) {
      pp <<= 1;
      z = ml(z, z, x);
      if (z == 1) return false;
      if (z == x - 1) {
        ok = true;
        break;
      }
    }
    if (!ok) return false;
  }
  return true;
}
long long sl(long long x) {
  int c = rand() % x, z = 1, i = 0;
  long long a = 2, b = 2;
  while (true) {
    a = add(ml(a, a, x), c, x);
    long long g = gcd(a - b + x, x);
    if (g > 1) return g;
    if (++i == z) z <<= 1, b = a;
  }
}
vector<pair<long long, int> > fac(long long x) {
  if (isp(x)) return vector<pair<long long, int> >{{x, 1}};
  long long z = x;
  while (z == x) z = sl(x);
  vector<pair<long long, int> > v1 = fac(z), v2 = fac(x / z), an;
  int i = 0, j = 0;
  while (i < v1.size() && j < v2.size()) {
    if (v1[i].first == v2[j].first)
      an.push_back(make_pair(v1[i].first, v1[i].second + v2[j].second)), ++i,
          ++j;
    else if (v1[i].first < v2[j].first)
      an.push_back(v1[i]), ++i;
    else
      an.push_back(v2[j]), ++j;
  }
  while (i < v1.size()) an.push_back(v1[i]), ++i;
  while (j < v2.size()) an.push_back(v2[j]), ++j;
  return an;
}
int main() {
  srand(time(0));
  scanf("%d%lld%lld", &n, &m, &p);
  if (gcd(m, p) != 1) {
    for (int i = 2; i < m && v.size() < n; ++i)
      if (gcd(i, m) == 1) v.push_back(i);
    fn(v);
  }
  if (m <= MX) {
    long long x = p;
    while (!vis[x]) vis[x] = true, x = ml(x, p, m);
    for (int i = 2; i < m && v.size() < n; ++i)
      if (!vis[i] && gcd(i, m) == 1) v.push_back(i);
    fn(v);
  }
  int k = 60;
  long long z, w;
  while (k > 1) {
    z = pow(m, 1.0 / k) + 0.5;
    w = 1;
    for (int j = 0; j < (int)(k); ++j) {
      if (w >= m) {
        w = 0;
        break;
      }
      w *= z;
    }
    if (w == m) break;
    --k;
  }
  if (k == 1) z = m;
  long long mu = z - 1;
  for (int i = 1; i < (int)(k); ++i) mu *= z;
  vector<pair<long long, int> > fc = fac(mu);
  long long cl = mu;
  for (int i = 0; i < (int)(fc.size()); ++i)
    while (cl % fc[i].first == 0 && pw(p, cl / fc[i].first, m) == 1)
      cl /= fc[i].first;
  if (mu == cl) no();
  if (z == 2 && k > 2) {
    if (cl * 2 == mu) {
      if (p % 4 == 3) {
        long long z = 5;
        for (int i = 0; i < (int)(n); ++i) v.push_back(z), z = ml(z, m - 5, m);
      } else {
        long long z = 5;
        for (int i = 0; i < (int)(n); ++i) v.push_back(m - z), z = ml(z, 5, m);
      }
    } else {
      long long z = 5;
      for (int i = 0; i < (int)(n); ++i) v.push_back(z), z = ml(z, 25 % m, m);
    }
    fn(v);
  }
  long long q;
  while (true) {
    while (gcd(q = rand() % (m - 2) + 2, m) != 1)
      ;
    bool ok = true;
    for (int i = 0; i < (int)(fc.size()); ++i)
      if (pw(q, mu / fc[i].first, m) == 1) {
        ok = false;
        break;
      }
    if (ok) break;
  }
  int j = 1;
  long long bad = mu / cl;
  w = q;
  for (int i = 0; i < (int)(n); ++i) {
    if (j % bad)
      v.push_back(w);
    else
      --i;
    w = ml(w, q, m);
    ++j;
  }
  fn(v);
}
