#P6523. 「Wdoi-1」加密通信
「Wdoi-1」加密通信
Description
First, Eirin Yagokoro writes the plaintext to be encrypted. This plaintext consists of positive integers.
Then, she constructs a ciphertext consisting of prime numbers, satisfying that for all , .
To improve the efficiency of information usage, Eirin Yagokoro requires that the values of all primes appearing in must be within the range .
Input Format
The first line contains an integer , representing the number of plaintext groups to be encrypted.
For each group of plaintext:
The first line contains two integers , representing (plaintext length ), i.e., the length of the ciphertext to be found, and the maximum value of primes allowed to appear.
The next line contains positive integers separated by spaces, representing the plaintext .
Output Format
For each group of plaintext, output one line:
-
If a solution exists, output any valid ciphertext . The primes in the ciphertext should be separated by spaces.
-
If no solution exists, output
-1.
2
4 233
55 35 77
4 5
55 35 77
11 5 7 11
-1
Hint
Constraints
-
For of the testdata, , .
-
For of the testdata, .
-
For of the testdata, .
-
For of the testdata, , , .
-
The above subtasks are inclusive: includes , includes , , and so on.
Data Guarantee
-
If the condition that must be within is ignored, there is guaranteed to be at least one valid solution.
-
There exists at least one pair such that .
Additional Material
This material is not very relevant to solving the problem.
Translated by ChatGPT 5
京公网安备 11011102002149号