#include <bits/stdc++.h>
using namespace std;
int sv[1000001], n, m, x, cnt[1000001], res[1000001], k = 0;
vector<int> vec[1000001], gen;
void generate(int n) {
  if (n == 1)
    gen.push_back(1);
  else {
    int now = n, k = 0;
    while (now % sv[n] == 0) now /= sv[n], k++;
    generate(now);
    int size = gen.size();
    for (int i = 0, carry = sv[n]; i < k; i++) {
      for (int j = 0; j < size; j++) gen.push_back(gen[j] * carry);
      carry *= sv[n];
    }
  }
}
int main() {
  sv[1] = 1;
  for (int i = 2; i < 1000001; i++) {
    if (sv[i] != 0) continue;
    for (int j = i; j < 1000001; j += i) sv[j] = i;
  }
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x <= m) cnt[x]++, vec[x].push_back(i + 1);
  }
  int maxlength = 0, whenlcm = 1;
  for (int lcm = m; lcm > 0; lcm--) {
    int ans = 0;
    gen.clear();
    generate(lcm);
    for (int i = 0; i < (int)gen.size(); i++) {
      ans += cnt[gen[i]];
    }
    if (ans > maxlength) {
      maxlength = ans;
      whenlcm = lcm;
    } else if (ans == maxlength && whenlcm > lcm)
      whenlcm = lcm;
  }
  printf("%d %d\n", whenlcm, maxlength);
  for (int j = 1; j * j <= whenlcm; j++) {
    if (whenlcm % j == 0) {
      for (int i = 0; i < cnt[j]; i++) res[k++] = vec[j][i];
      if (j * j != whenlcm)
        for (int i = 0; i < cnt[whenlcm / j]; i++)
          res[k++] = vec[whenlcm / j][i];
    }
  }
  sort(res, res + k);
  for (int i = 0; i < k; i++) printf("%d ", res[i]);
  return 0;
}
