#include <bits/stdc++.h>
template <typename T>
inline T max(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
inline T min(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline bool repr(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool repl(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline T gcd(T a, T b) {
  T t;
  if (a < b) {
    while (a) {
      t = a;
      a = b % a;
      b = t;
    }
    return b;
  } else {
    while (b) {
      t = b;
      b = a % b;
      a = t;
    }
    return a;
  }
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
struct Cg {
  __attribute__((always_inline)) inline char operator()() { return getchar(); }
};
struct Cp {
  __attribute__((always_inline)) inline void operator()(char x) { putchar(x); }
};
__attribute__((always_inline)) inline bool IS(char x) {
  return x == 10 || x == 13 || x == ' ';
}
template <typename T>
struct Fr {
  T P;
  __attribute__((always_inline)) inline Fr &operator,(int &x) {
    x = 0;
    unsigned char t = P();
    while ((t < '0' || t > '9') && t != '-') t = P();
    bool f = 0;
    if (t == '-') t = P(), f = 1;
    x = t - '0';
    for (t = P(); t >= '0' && t <= '9'; t = P()) x = x * 10 + t - '0';
    if (f) x = -x;
    return *this;
  }
  __attribute__((always_inline)) inline operator int() {
    int x;
    *this, x;
    return x;
  }
  __attribute__((always_inline)) inline Fr &operator,(long long &x) {
    x = 0;
    unsigned char t = P();
    while ((t < '0' || t > '9') && t != '-') t = P();
    bool f = 0;
    if (t == '-') t = P(), f = 1;
    x = t - '0';
    for (t = P(); t >= '0' && t <= '9'; t = P()) x = x * 10 + t - '0';
    if (f) x = -x;
    return *this;
  }
  __attribute__((always_inline)) inline operator long long() {
    long long x;
    *this, x;
    return x;
  }
  __attribute__((always_inline)) inline Fr &operator,(char &x) {
    for (x = P(); IS(x); x = P())
      ;
    return *this;
  }
  __attribute__((always_inline)) inline operator char() {
    char x;
    *this, x;
    return x;
  }
  __attribute__((always_inline)) inline Fr &operator,(char *x) {
    char t = P();
    for (; IS(t); t = P())
      ;
    if (~t) {
      for (; !IS(t) && ~t; t = P()) *x++ = t;
    }
    *x++ = 0;
    return *this;
  }
  __attribute__((always_inline)) inline Fr &operator,(double &x) {
    x = 0;
    unsigned char t = P();
    while ((t < '0' || t > '9') && t != '-') t = P();
    bool f = 0;
    if (t == '-') t = P(), f = 1;
    x = t - '0';
    for (t = P(); t >= '0' && t <= '9'; t = P()) x = x * 10 + t - '0';
    if (t == '.') {
      double u = 0.1;
      for (t = P(); t >= '0' && t <= '9'; t = P(), u *= 0.1) x += u * (t - '0');
    }
    if (f) x = -x;
    return *this;
  }
  __attribute__((always_inline)) inline operator double() {
    double x;
    *this, x;
    return x;
  }
  __attribute__((always_inline)) inline Fr &operator,(long double &x) {
    x = 0;
    unsigned char t = P();
    while ((t < '0' || t > '9') && t != '-') t = P();
    bool f = 0;
    if (t == '-') t = P(), f = 1;
    x = t - '0';
    for (t = P(); t >= '0' && t <= '9'; t = P()) x = x * 10 + t - '0';
    if (t == '.') {
      double u = 0.1;
      for (t = P(); t >= '0' && t <= '9'; t = P(), u *= 0.1) x += u * (t - '0');
    }
    if (f) x = -x;
    return *this;
  }
  __attribute__((always_inline)) inline operator long double() {
    long double x;
    *this, x;
    return x;
  }
  __attribute__((always_inline)) inline Fr &operator,(unsigned int &x) {
    x = 0;
    unsigned char t = P();
    while (t < '0' || t > '9') t = P();
    x = t - '0';
    for (t = P(); t >= '0' && t <= '9'; t = P()) x = x * 10 + t - '0';
    return *this;
  }
  __attribute__((always_inline)) inline operator unsigned int() {
    unsigned int x;
    *this, x;
    return x;
  }
  __attribute__((always_inline)) inline Fr &operator,(unsigned long long &x) {
    x = 0;
    unsigned char t = P();
    while (t < '0' || t > '9') t = P();
    x = t - '0';
    for (t = P(); t >= '0' && t <= '9'; t = P()) x = x * 10 + t - '0';
    return *this;
  }
  __attribute__((always_inline)) inline operator unsigned long long() {
    unsigned long long x;
    *this, x;
    return x;
  }
};
Fr<Cg> in;
template <typename T>
struct Fw {
  T P;
  __attribute__((always_inline)) inline Fw &operator,(int x) {
    if (x) {
      if (x < 0) P('-'), x = -x;
      unsigned char s[10], c = 0;
      while (x) s[c++] = x % 10 + '0', x /= 10;
      while (c--) P(s[c]);
    } else
      P('0');
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator()(int x) {
    if (x) {
      if (x < 0) P('-'), x = -x;
      unsigned char s[10], c = 0;
      while (x) s[c++] = x % 10 + '0', x /= 10;
      while (c--) P(s[c]);
    } else
      P('0');
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator,(unsigned int x) {
    if (x) {
      unsigned char s[10], c = 0;
      while (x) s[c++] = x % 10 + '0', x /= 10;
      while (c--) P(s[c]);
    } else
      P('0');
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator()(unsigned int x) {
    if (x) {
      unsigned char s[10], c = 0;
      while (x) s[c++] = x % 10 + '0', x /= 10;
      while (c--) P(s[c]);
    } else
      P('0');
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator,(long long x) {
    if (x) {
      if (x < 0) P('-'), x = -x;
      unsigned char s[19], c = 0;
      while (x) s[c++] = x % 10 + '0', x /= 10;
      while (c--) P(s[c]);
    } else
      P('0');
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator()(long long x) {
    if (x) {
      if (x < 0) P('-'), x = -x;
      unsigned char s[19], c = 0;
      while (x) s[c++] = x % 10 + '0', x /= 10;
      while (c--) P(s[c]);
    } else
      P('0');
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator,(unsigned long long x) {
    if (x) {
      unsigned char s[20], c = 0;
      while (x) s[c++] = x % 10 + '0', x /= 10;
      while (c--) P(s[c]);
    } else
      P('0');
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator()(unsigned long long x) {
    if (x) {
      unsigned char s[20], c = 0;
      while (x) s[c++] = x % 10 + '0', x /= 10;
      while (c--) P(s[c]);
    } else
      P('0');
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator,(char x) {
    P(x);
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator()(char x) {
    P(x);
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator,(const char *x) {
    while (*x) P(*x++);
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator()(const char *x) {
    while (*x) P(*x++);
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator()(double x, int y) {
    if (y) {
      double t = 0.5;
      for (int i = y; i--;) t *= 0.1;
      if (x >= 0)
        x += t;
      else
        x -= t, P('-');
      *this, (long long)(abs(x));
      P('.');
      if (x < 0) x = -x;
      while (y--) {
        x *= 10;
        x -= floor(x * 0.1) * 10;
        P(((int)x) % 10 + '0');
      }
    } else if (x >= 0)
      *this, (long long)(x + 0.5);
    else
      *this, (long long)(x - 0.5);
    ;
    return *this;
  }
  __attribute__((always_inline)) inline Fw &operator()(long double x, int y) {
    if (y) {
      double t = 0.5;
      for (int i = y; i--;) t *= 0.1;
      if (x >= 0)
        x += t;
      else
        x -= t, P('-');
      *this, (long long)(abs(x));
      P('.');
      if (x < 0) x = -x;
      while (y--) {
        x *= 10;
        x -= floor(x * 0.1) * 10;
        P(((int)x) % 10 + '0');
      }
    } else if (x >= 0)
      *this, (long long)(x + 0.5);
    else
      *this, (long long)(x - 0.5);
    ;
    return *this;
  }
};
Fw<Cp> out;
inline unsigned long long mrand() {
  static unsigned long long s = 124124124713812490;
  return s += s << 2 | 1;
}
inline long long mul(long long a, long long b, long long c) {
  a %= c, b %= c;
  long long t = a * b - (long long)((long double)a * b / c + 0.5) * c;
  if (t < 0) return t + c;
  return t;
}
inline long long pow(long long a, long long b, long long c) {
  long long r = 1;
  for (; b; b >>= 1, a = mul(a, a, c))
    if (b & 1) r = mul(a, r, c);
  return r;
}
std::map<long long, int> ys;
inline bool mr(long long x) {
  if (x == 2) return 1;
  if (x < 2 || (~x & 1)) return 0;
  long long u = x - 1, p, a, b;
  int t = 0;
  while (~u & 1) u >>= 1, t++;
  for (int i = 0, iend = 5; i < iend; i++) {
    p = mrand() % (x - 1) + 1;
    a = pow(p, u, x);
    for (int j = 0, jend = t; j < jend; j++) {
      b = mul(a, a, x);
      if (b == 1 && a != 1 && a != x - 1) return 0;
      a = b;
    }
    if (a != 1) return 0;
  }
  return 1;
}
inline long long f(long long a, long long b, long long n) {
  return (mul(a, a, n) + b) % n;
}
void pr(long long n) {
  if (n == 1) return;
  if (mr(n)) {
    ys[n]++;
    return;
  }
  if (n == 4) {
    ys[2] += 2;
    return;
  }
  long long a, x, y, p;
  while (1) {
    a = mrand() & 63, x = y = 2;
    while (1) {
      x = f(x, a, n), y = f(f(y, a, n), a, n);
      if (x == y) break;
      p = gcd(n, abs(x - y));
      if (p > 1) {
        pr(p), pr(n / p);
        return;
      }
    }
  }
}
int n, mc;
long long m, ma, p, phi;
inline long long spow(long long a, long long b) {
  long long r = 1;
  while (b) b--, r *= a;
  return r;
}
inline long long qpow(long long a, long long b) {
  long long r = 1;
  for (; b; b >>= 1, a = mul(a, a, m))
    if (b & 1) r = mul(r, a, m);
  return r;
}
inline void solve2() {
  long long t = 4;
  while ((p % t == 1 || p % t == t - 1) && t <= m) t <<= 1;
  if (p == 1) {
    std::vector<long long> ans;
    for (long long i = 3; i < m; i++) {
      if (i & 1) ans.push_back(i);
      if (ans.size() == n) break;
    }
    if (ans.size() != n) {
      out, -1, '\n';
    } else {
      for (__typeof((ans).end()) i = (ans).begin(); i != (ans).end(); ++i)
        out, *i, ' ';
      out, '\n';
    }
    return;
  }
  long long pt = p % t;
  {
    std::vector<long long> ans;
    for (long long i = 0; i < m; i++) {
      bool tt = (i & (t - 1)) == pt || (i & (t - 1)) == 1;
      if ((i & 1) && !tt) ans.push_back(i);
      if (ans.size() == n) break;
    }
    if (ans.size() != n) {
      out, -1, '\n';
    } else {
      for (__typeof((ans).end()) i = (ans).begin(); i != (ans).end(); ++i)
        out, *i, ' ';
      out, '\n';
    }
  }
}
int main() {
  in, n, m, p;
  for (int i = 2, iend = 2333; i <= iend; i++) {
    if (m % i == 0) {
      ma = i;
      while (m > 1) m /= i, mc++;
      break;
    }
  }
  if (!ma) {
    for (int i = 7; i; i--) {
      long long t = expl(logl(m) / i);
      while (spow(t, i) <= m) t++;
      while (spow(t, i) > m) t--;
      if (spow(t, i) == m) {
        ma = t, mc = i;
        break;
      }
    }
  }
  m = spow(ma, mc);
  if (p % ma == 0) {
    std::vector<long long> ans;
    for (long long i = 2; i < m; i++) {
      if (i % ma) ans.push_back(i);
      if (ans.size() == n) break;
    }
    if (ans.size() != n) {
      out, -1, '\n';
    } else {
      for (__typeof((ans).end()) i = (ans).begin(); i != (ans).end(); ++i)
        out, *i, ' ';
      out, '\n';
    }
    return 0;
  }
  if (ma == 2) return solve2(), 0;
  phi = spow(ma, mc - 1) * (ma - 1);
  pr(ma - 1);
  for (int i = 0, iend = mc - 1; i < iend; i++) ys[ma]++;
  long long up = phi;
  assert(qpow(p, up) == 1);
  for (__typeof((ys).end()) i = (ys).begin(); i != (ys).end(); ++i) {
    while (up % i->first == 0) {
      if (qpow(p, up / i->first) == 1)
        up /= i->first;
      else
        break;
    }
  }
  if (m - spow(ma, mc - 1) - up < n) {
    out, -1, '\n';
    return 0;
  }
  std::vector<long long> ans;
  for (long long i = 0; i < m; i++) {
    if ((i % ma) && qpow(i, up) != 1) ans.push_back(i);
    if (ans.size() == n) break;
  }
  for (__typeof((ans).end()) i = (ans).begin(); i != (ans).end(); ++i)
    out, *i, ' ';
  out, '\n';
}
