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 (1 ≤ n ≤ 100, 1 ≤ m ≤ 10000). Second line contains n integers A1
, A2
, ..., An
(0 ≤ Ai
≤ 10000).
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.
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