#include <bits/stdc++.h>
using namespace std;
template <class T>
void splitstr(const string &s, vector<T> &out) {
  istringstream in(s);
  out.clear();
  copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
static void redirect(int argc, const char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (argc > 1) {
    static filebuf f;
    f.open(argv[1], ios::in);
    cin.rdbuf(&f);
    if (!cin) {
      cerr << "Failed to open '" << argv[1] << "'" << endl;
      exit(1);
    }
  }
  if (argc > 2) {
    static filebuf f;
    f.open(argv[2], ios::out | ios::trunc);
    cout.rdbuf(&f);
    if (!cout) {
      cerr << "Failed to open '" << argv[2] << "'" << endl;
    }
  }
}
static unsigned long long matp2mod(unsigned long long a, int k,
                                   unsigned long long m) {
  a %= m;
  for (int i = 0; i < k; i++) {
    a <<= 1;
    if (a >= m) a -= m;
  }
  return a;
}
static long long matmod(unsigned long long a, unsigned long long b,
                        unsigned long long m) {
  unsigned long long al = a & UINT_MAX;
  unsigned long long ah = a >> 32;
  unsigned long long bl = b & UINT_MAX;
  unsigned long long bh = b >> 32;
  unsigned long long ans1 = al * bl % m;
  unsigned long long ans2 = matp2mod(al * bh % m + ah * bl % m, 32, m);
  unsigned long long ans3 = matp2mod(ah * bh, 64, m);
  return (ans1 + ans2 + ans3) % m;
}
static long long powermod(long long a, long long b, long long m) {
  if (b == 0)
    return 1;
  else if (b & 1)
    return matmod(a, powermod(a, b - 1, m), m);
  else {
    long long t = powermod(a, b / 2, m);
    return matmod(t, t, m);
  }
}
static bool is_prime(long long n) {
  if (n <= 1)
    return false;
  else if (n < 64)
    return (0x28208a20a08a28acULL >> n) & 1;
  else if (n % 2 == 0)
    return false;
  else if (n < 1000000) {
    for (int i = 3; i * i <= n; i += 2)
      if (n % i == 0) return false;
    return true;
  } else {
    long long d = n - 1;
    int r = 0;
    while (!(d & 1)) {
      d >>= 1;
      r++;
    }
    for (long long a = 2; a <= 37; a++)
      if (is_prime(a)) {
        long long x = powermod(a, d, n);
        if (x == 1 || x == n - 1) continue;
        int i;
        for (i = 0; i < r - 1; i++) {
          x = matmod(x, x, n);
          if (x == n - 1) break;
        }
        if (i == r - 1) return false;
      }
    return true;
  }
}
static long long pollard_rho(long long n) {
  std::mt19937_64 engine;
  std::uniform_int_distribution<long long> pick(2, n - 2);
  while (true) {
    long long a, b, s;
    a = b = pick(engine);
    s = pick(engine);
    while (true) {
      a = (matmod(a, a, n) + s) % n;
      b = (matmod(b, b, n) + s) % n;
      b = (matmod(b, b, n) + s) % n;
      if (a == b) break;
      long long g = gcd(llabs(a - b), n);
      if (g > 1) return g;
    }
  }
}
static std::vector<std::pair<long long, int>> factorise(long long n) {
  std::vector<std::pair<long long, int>> out;
  if (n < 1000000) {
    for (int i = 2; i * i <= n; i++)
      if (n % i == 0) {
        n /= i;
        int r = 1;
        while (n % i == 0) {
          n /= i;
          r++;
        }
        out.emplace_back(i, r);
      }
    if (n > 1) out.emplace_back(n, 1);
  } else if (is_prime(n)) {
    out.emplace_back(n, 1);
  } else {
    long long a = pollard_rho(n);
    auto fa = factorise(a);
    auto fb = factorise(n / a);
    auto pa = fa.begin();
    auto pb = fb.begin();
    while (pa != fa.end() && pb != fb.end()) {
      if (pa->first == pb->first) {
        out.emplace_back(pa->first, pa->second + pb->second);
        ++pa;
        ++pb;
      } else if (pa->first < pb->first)
        out.push_back(*pa++);
      else
        out.push_back(*pb++);
    }
    std::copy(pa, fa.end(), std::back_inserter(out));
    std::copy(pb, fb.end(), std::back_inserter(out));
  }
  return out;
}
static long long order(long long x, long long M, long long phi,
                       const vector<pair<long long, int>> &factors) {
  long long ans = phi;
  for (const auto &e : factors) {
    while (ans % e.first == 0 && powermod(x, ans / e.first, M) == 1)
      ans /= e.first;
  }
  return ans;
}
int main(int argc, const char **argv) {
  redirect(argc, argv);
  long long N, M, P;
  cin >> N >> M >> P;
  auto factors = factorise(M);
  long long Q = factors[0].first;
  int K = factors[0].second;
  factors = factorise(Q - 1);
  if (K > 1) factors.emplace_back(Q, K - 1);
  long long phi = 1;
  for (const auto &e : factors)
    for (int i = 0; i < e.second; i++) phi *= e.first;
  if (gcd(P, M) > 1) P = 1;
  long long ordP = order(P, M, phi, factors);
  long long good = phi - ordP;
  if (good < N) {
    cout << "-1\n";
    return 0;
  }
  vector<long long> out;
  mt19937_64 engine;
  uniform_int_distribution<long long> dist(2, M - 1);
  long long g;
  if (Q != 2 || K <= 2) {
    do {
      g = dist(engine);
    } while (gcd(g, M) != 1 || order(g, M, phi, factors) != phi);
    long long cur = 1;
    long long step = phi / ordP;
    for (long long i = 1; ((long long)(out).size()) < N; i++) {
      cur = matmod(cur, g, M);
      if (i % step != 0) out.push_back(cur);
    }
  } else {
    bool P1 = (P % 4 == 1);
    if (P1) {
      for (long long i = 3; i < M && ((long long)(out).size()) < N; i += 4)
        out.push_back(i);
    }
    do {
      g = dist(engine);
    } while (g % 4 != 1 || gcd(g, M) != 1 ||
             order(g, M, phi, factors) != phi / 2);
    long long cur = 1;
    long long step = phi / (P1 ? 2 * ordP : ordP);
    for (long long i = 1; ((long long)(out).size()) < N; i++) {
      cur = matmod(cur, g, M);
      if (i % step != 0) {
        out.push_back(cur);
        if (!P1 && ((long long)(out).size()) < N)
          out.push_back(matmod(P, cur, M));
      }
    }
  }
  for (long long v : out) cout << v << ' ';
  cout << '\n';
  return 0;
}
