#include <bits/stdc++.h>
using namespace std;
long long lcm[1000005];
vector<long long> p[1000005];
set<long long> s;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, l = 0, k, x;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    x = min(x, m + 1);
    p[x].push_back(i + 1);
  }
  for (long long i = 1; i <= m; i++) {
    x = p[i].size();
    for (long long j = i; j <= m; j += i) lcm[j] += x;
  }
  for (long long i = 1; i <= m; i++) {
    if (l < lcm[i]) {
      l = lcm[i];
      k = i;
    }
  }
  if (l == 0) {
    cout << 1 << " " << 0;
  } else {
    cout << k << " " << l << endl;
    for (long long i = 1; i * i <= k; i++) {
      if (k % i == 0) {
        if (p[k / i].size() > 0) {
          for (long long j = 0; j < p[k / i].size(); j++) s.insert(p[k / i][j]);
        }
        if (p[i].size() > 0) {
          for (long long j = 0; j < p[i].size(); j++) s.insert(p[i][j]);
        }
      }
    }
    for (auto i = s.begin(); i != s.end(); i++) cout << (*i) << " ";
  }
}
