PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000102. Dãy con dài nhất với BCNN bị chặn (Longest Subsequence)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Dãy con dài nhất với BCNN bị chặn (Longest Subsequence)

Longest Subsequence

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array a1,…,ana_1,\ldots,a_n of positive integers and a limit mm, choose a longest subsequence whose LCM does not exceed mm. The subsequence must preserve the original order. The LCM of an empty subsequence is defined as 11. Any maximum-length valid subsequence is accepted.

Input

The first line contains n,mn,m. The second line contains nn elements aia_i.

Output

The first line prints the actual LCM ll and the optimal length kk. The second line prints exactly kk strictly increasing selected indices. For k=0k=0, the second line is empty.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30, 1≤m≤10001\le m\le 1000, 1≤ai≤1041\le a_i\le 10^4.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000, 1≤m≤1051\le m\le 10^5, 1≤ai≤1071\le a_i\le 10^7.
  • Subtask 3 (50 points): 1≤n,m≤1061\le n,m\le 10^6, 1≤ai≤1091\le a_i\le 10^9.

Examples

Input

7 8
6 2 9 2 7 2 3

Output

6 5
1 2 4 6 7

Explanation

Selecting positions 1,2,4,6,71,2,4,6,7 yields 6,2,2,2,36,2,2,2,3, whose LCM is 6≤86\le8. Its length is 55, the maximum achievable.