Codeforces Round 573 (Div. 1)
F
Tokitsukaze and Powers
Codeforces
3400
原题
← E→
翻译中…

Tokitsukaze is playing a room escape game designed by SkywalkerT. In this game, she needs to find out hidden clues in the room to reveal a way to escape.

翻译中…

After a while, she realizes that the only way to run away is to open the digital door lock since she accidentally went into a secret compartment and found some clues, which can be interpreted as:

翻译中…
  • Only when you enter $n$ possible different passwords can you open the door;
  • Passwords must be integers ranged from $0$ to $(m - 1)$;
  • A password cannot be $x$ ($0 \leq x \lt m$) if $x$ and $m$ are not coprime (i.e. $x$ and $m$ have some common divisor greater than $1$);
  • A password cannot be $x$ ($0 \leq x \lt m$) if there exist non-negative integers $e$ and $k$ such that $p^e = k m + x$, where $p$ is a secret integer;
  • Any integer that doesn't break the above rules can be a password;
  • Several integers are hidden in the room, but only one of them can be $p$.
翻译中…

Fortunately, she finds that $n$ and $m$ are recorded in the lock. However, what makes Tokitsukaze frustrated is that she doesn't do well in math. Now that she has found an integer that is suspected to be $p$, she wants you to help her find out $n$ possible passwords, or determine the integer cannot be $p$.

翻译中…

Input

翻译中…

The only line contains three integers $n$, $m$ and $p$ ($1 \leq n \leq 5 \times 10^5$, $1 \leq p \lt m \leq 10^{18}$).

翻译中…

It is guaranteed that $m$ is a positive integer power of a single prime number.

翻译中…

Output

翻译中…

If the number of possible different passwords is less than $n$, print a single integer $-1$.

翻译中…

Otherwise, print $n$ distinct integers ranged from $0$ to $(m - 1)$ as passwords. You can print these integers in any order. Besides, if there are multiple solutions, print any.

翻译中…

Note

翻译中…

In the first example, there is no possible password.

翻译中…

In each of the last three examples, the given integer $n$ equals to the number of possible different passwords for the given integers $m$ and $p$, so if the order of numbers in the output is ignored, the solution is unique as shown above.

翻译中…

样例

Input #1
1 2 1
Output #1
-1
InputCopy OutputCopy
Input #2
3 5 1
Output #2
2 4 3
InputCopy OutputCopy
Input #3
2 5 4
Output #3
2 3
InputCopy OutputCopy
Input #4
4 9 8
Output #4
2 4 7 5
InputCopy OutputCopy
题目信息
题号
1190F
时间限制
3 s
内存限制
256 MB
标签
数论
概率论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。