#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  x *= f;
}
vector<int> pos[1000010];
int a[1000010];
int n, m;
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
    if (a[i] <= m) {
      pos[a[i]].push_back(i);
    }
  }
  vector<int> cnt(10 + m);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m / i; j++) {
      cnt[i * j] += pos[i].size();
    }
  }
  int sol = max(1, (int)(max_element(cnt.begin(), cnt.end()) - cnt.begin()));
  priority_queue<int, vector<int>, greater<int> > ans;
  for (int i = 1; i <= sol; i++) {
    if (sol % i == 0) {
      for (int 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();
  } else {
    cout << 0 << endl;
  }
  while (!ans.empty()) {
    cout << " " << ans.top();
    ans.pop();
  }
  cout << endl;
  return 0;
}
