VK Cup 2017 - Round 2
C
Vulnerable Kerbals
Codeforces
2300
原题
← BD →
翻译中…

You are given an integer $*m*$, and a list of $*n*$ distinct integers between $0$ and $*m* - 1$.

翻译中…

You would like to construct a sequence satisfying the properties:

翻译中…
  • Each element is an integer between $0$ and $*m* - 1$, inclusive.
  • All prefix products of the sequence modulo $*m*$ are distinct.
  • No prefix product modulo $*m*$ appears as an element of the input list.
  • The length of the sequence is maximized.
翻译中…

Construct any sequence satisfying the properties above.

翻译中…

Input

翻译中…

The first line of input contains two integers $*n*$ and $*m*$ ($0 ≤ *n* < *m* ≤ 200 000$) — the number of forbidden prefix products and the modulus.

翻译中…

If $*n*$ is non-zero, the next line of input contains $*n*$ distinct integers between $0$ and $*m* - 1$, the forbidden prefix products. If $*n*$ is zero, this line doesn't exist.

翻译中…

Output

翻译中…

On the first line, print the number $*k*$, denoting the length of your sequence.

翻译中…

On the second line, print $*k*$ space separated integers, denoting your sequence.

翻译中…

Note

翻译中…

For the first case, the prefix products of this sequence modulo $*m*$ are $[1, 2, 3, 4, 0]$.

翻译中…

For the second case, the prefix products of this sequence modulo $*m*$ are $[3, 7, 4, 6, 8, 0]$.

翻译中…

样例

Input #1
0 5
Output #1
5
1 2 4 3 0
InputCopy OutputCopy
Input #2
3 10
2 9 1
Output #2
6
3 9 2 9 8 0
InputCopy OutputCopy
题目信息
题号
772C
时间限制
2 s
内存限制
256 MB
标签
构造
动态规划
图论
数学
数论

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