#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double EPS = 1e-9;
const long long mod = 1000000007ll;
const int maxn = (int)1000500 + 10;
int cnt[maxn], cntD[maxn], a[maxn];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(n); ++i)
    scanf("%d", &a[i]), (a[i] <= m) ? cnt[a[i]]++ : 0;
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j += i) cntD[j] += cnt[i];
  int ans = 1, ansCnt = cntD[1];
  for (int i = 1; i <= m; i++)
    if (cntD[i] > ansCnt) ansCnt = cntD[i], ans = i;
  printf("%d %d\n", ans, ansCnt);
  for (int i = 0; i < (int)(n); ++i)
    if (ans % a[i] == 0) printf("%d ", i + 1);
}
