#include <bits/stdc++.h>
using namespace std;
const long long mx = 1000005;
long long n, m;
long long ara[mx];
long long cnt[mx];
const long long N = 1003;
bool mark[N];
vector<long long> prime;
void sieve() {
  long long limit = sqrt(N) + 5;
  mark[1] = true;
  prime.push_back(2);
  for (long long i = 4; i < N; i += 2) mark[i] = true;
  for (long long i = 3; i < N; i += 2) {
    if (!mark[i]) {
      prime.push_back(i);
      if (i <= limit) {
        for (long long j = i * i; j < N; j += 2 * i) mark[j] = true;
      }
    }
  }
}
vector<pair<long long, long long> > factor;
long long func(long long idx, long long div) {
  if (idx >= factor.size()) return cnt[div];
  long long prim = 1;
  long long ret = 0;
  for (long long i = 0; i <= factor[idx].second; i++) {
    ret += func(idx + 1, prim * div);
    prim *= factor[idx].first;
  }
  return ret;
}
long long sol(long long lcm) {
  factor.clear();
  for (long long i = 0;
       i < (long long)prime.size() and prime[i] * prime[i] <= lcm; i++) {
    if (lcm % prime[i] == 0) {
      long long cnt = 0;
      while (lcm % prime[i] == 0) {
        lcm /= prime[i];
        cnt++;
      }
      factor.push_back(make_pair(prime[i], cnt));
    }
  }
  if (lcm > 1) factor.push_back(make_pair(lcm, 1));
  long long ret = func(0, 1);
  return ret;
}
int main() {
  sieve();
  scanf("%lld %lld", &n, &m);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &ara[i]);
    if (ara[i] <= m) {
      cnt[ara[i]]++;
    }
  }
  long long ans = 0;
  long long lcm = 1;
  for (long long i = 1; i <= m; i++) {
    long long temp = sol(i);
    if (ans < temp) {
      ans = temp;
      lcm = i;
    }
  }
  printf("%lld %lld\n", lcm, ans);
  bool first = true;
  bool taken[mx];
  memset(taken, false, sizeof taken);
  for (long long i = 1; i <= sqrt(lcm); i++) {
    if (lcm % i == 0) {
      long long d1 = i;
      long long d2 = lcm / i;
      taken[d1] = true;
      taken[d2] = true;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (ara[i] <= m) {
      if (taken[ara[i]] == true) {
        if (first)
          printf("%lld", i + 1), first = false;
        else
          printf(" %lld", i + 1);
      }
    }
  }
  printf("\n");
}
