#abc173e. [abc173_e]Multiplication 4
[abc173_e]Multiplication 4
Problem Statement
Given are integers .
We will choose exactly of these elements. Find the maximum possible product of the chosen elements.
Then, print the maximum product modulo , using an integer between and (inclusive).
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the maximum product modulo , using an integer between and (inclusive).
Sample Input 1
4 2
1 2 -3 -4
Sample Output 1
12
The possible products of the two chosen elements are , , , , , and , so the maximum product is .
Sample Input 2
4 3
-1 -2 -3 -4
Sample Output 2
1000000001
The possible products of the three chosen elements are , , , and , so the maximum product is .
We print this value modulo , that is, .
Sample Input 3
2 1
-1 1000000000
Sample Output 3
1000000000
The possible products of the one chosen element are and , so the maximum product is .
Sample Input 4
10 10
1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1
Sample Output 4
999983200
Be sure to print the product modulo .