#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x;
}
priority_queue<long long, vector<long long>, greater<long long> > ans;
vector<long long> pos[1000010];
long long n, m, a[1000010];
signed main() {
  n = read();
  m = read();
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] > m) continue;
    pos[a[i]].push_back(i);
  }
  vector<long long> cnt(m + 10);
  for (long long i = 1; i <= m; i++) {
    for (long long j = 1; j <= m / i; j++) {
      cnt[i * j] += pos[i].size();
    }
  }
  long long sol =
      max(1ll, (long long)(max_element(cnt.begin(), cnt.end()) - cnt.begin()));
  for (long long i = 1; i <= sol; i++) {
    if (sol % i == 0) {
      for (long long j = 0; j < pos[i].size(); j++) ans.push(pos[i][j]);
    }
  }
  cout << sol << " ";
  if (ans.size() >= 1) {
    cout << ans.size() << endl << ans.top();
    ans.pop();
    while (!ans.empty()) {
      cout << " " << ans.top();
      ans.pop();
    }
  } else {
    puts("0");
  }
  return 0;
}
