#include <bits/stdc++.h>
using namespace std;
int H[(int)(1e6 + 10)], i, j, k, n, m, x, y, z, a[(int)(1e6 + 10)];
int A[(int)(1e6 + 10)], ans, t;
vector<int> v;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    scanf("%d", a + i);
    if (a[i] <= m) H[a[i]]++;
  }
  for (i = 2; i <= m; i++)
    for (j = i; j <= m; j += i) A[j] += H[i];
  for (i = 1; i <= m; i++) {
    if (ans < H[1] + A[i]) {
      ans = H[1] + A[i];
      t = i;
    }
  }
  if (!t) {
    cout << 1 << ' ' << 0 << '\n';
    return 0;
  }
  cout << t << ' ';
  for (i = 1; i <= n; i++)
    if (t % a[i] == 0) v.push_back(i);
  cout << v.size() << '\n';
  for (i = 0; i < v.size(); i++) cout << v[i] << ' ';
  cout << '\n';
}
