eolymp
bolt
Try our new interface for solving problems
Problems

Product of numbers

Product of numbers

Given integers A1, A2, ..., An and number m.

Choose such subset of numbers A1, A2, ..., An so that their product taken modulo m is maximum.

Input

First line contains two integers n and m (1n100, 1m10000). Second line contains n integers A1, A2, ..., An (0Ai10000).

Output

Print in the first line numbers p and k - the product of chosen numbers by modulo m and the number of chosen numbers. Print in the second line k numbers B1, B2, ..., Bk - the indexes of chosen numbers. The indexes must be pairwise different. If there are multiple answers with maximum p, print any of them.

Time limit 1 second
Memory limit 122.49 MiB
Input example #1
3 5
1 2 3
Output example #1
3 2
3 1
Input example #2
5 8
5 4 3 2 1
Output example #2
7 3
5 3 1
Author Ivan Kazmenko
Source Lisiy Nos Training on Dynamic Programming, Part 1