#P6197. [EER1] 礼物

[EER1] 礼物

Description

Xiao Z gave you a sequence. Specifically, a1=1a_1=1, a2=2a_2=2, and ai=2ai1+kai2(3in)a_i=2a_{i-1}+ka_{i-2}(3\le i\le n), where nn is the length of the sequence, and kk is a positive integer parameter she set.

Xiao Z told you a secret: this sequence was carefully chosen by her and has a wonderful property called "Prime-smooth"—that is, for any prime pp not exceeding nn, it holds that papp\mid a_p (\mid denotes divisibility).

You were curious whether this was really true, so you wrote a prime generator and tried for three days and three nights. Finally, you found a few counterexamples: there are mm primes pip_i that do not satisfy the property Xiao Z mentioned.

Since you have randomized for a long time, you believe that other primes must satisfy the property.

To show that you and Xiao Z think alike, you now want to guess the parameter kk that Xiao Z set back then. Since the answer is very large, you only need to output the minimum kk modulo a prime cc.

Input Format

The first line contains three non-negative integers n,m,cn,m,c, with the same meanings as in the statement.

The next mm lines each contain a positive integer ii, meaning that the ii-th prime in increasing order, pip_i, does not satisfy piapip_i\mid a_{p_i}. We guarantee that this prime pinp_i\le n. Note: it is not guaranteed that these mm numbers are pairwise distinct.

Output Format

Output one integer: the value of the minimum kk modulo cc.

In particular, if there is no solution, output 1-1.

10 1 998244353
3
20
40 2 1018429441
1
4
-1

Hint

Sample 1 Explanation

Note that the 3rd prime is 55.

When k=20k=20, a2=2a_2=2, a3=24a_3=24, and a7=19264a_7=19264 all satisfy papp\mid a_p, and a5=656a_5=656 satisfies papp\nmid a_p.

Constraints

10n3×10810\le n\le 3\times 10^8.

n<c<230n\lt c\lt 2^{30}, c=a2d+1(d18)c=a\cdot 2^d+1(d\ge 18), and it is guaranteed that cc is prime.

0m200\le m\le 20.

Subtask ID nn\leq mm\leq Special Property Score
1 10610^6 2020 10
2 5×1075\times 10^7 20
3 2×1082\times 10^8 00 10
4 66
5 3×1083\times 10^8 00 c=998244353c=998244353 20
6
7 2020 10

Translated by ChatGPT 5