#include <bits/stdc++.h>
const int Inf = 2 * 1000 * 1000 * 1000;
long long LINF = (long long)4e18;
using namespace std;
const int nax = 1000 * 1000 + 5;
int a[nax];
int cnt[nax];
int z[nax];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] <= m) cnt[a[i]]++;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i) {
      z[j] += cnt[i];
    }
  }
  int mxval = -1, mxpos = -1;
  for (int i = 1; i <= m; i++) {
    if (mxval < z[i]) {
      mxval = z[i];
      mxpos = i;
    }
  }
  cout << mxpos << ' ' << mxval << '\n';
  for (int i = 0; i < n; i++) {
    if (mxpos % a[i] == 0) cout << i + 1 << ' ';
  }
  return 0;
}
