#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1000000 + 3];
int cnt[1000000 + 3];
int lcm[1000000 + 3];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  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 < 1000000 + 3; i++) {
    for (int j = i; j <= m; j += i) lcm[j] += cnt[i];
  }
  int ansL = 0, ansK = 0;
  for (int l = 1; l <= m; l++) {
    if (lcm[l] > ansK) {
      ansL = l;
      ansK = lcm[l];
    }
  }
  if (ansL == 0) {
    cout << 1 << " " << 0 << endl;
    return 0;
  }
  cout << ansL << " " << ansK << endl;
  for (int i = 0; i < n; i++) {
    if (ansL % a[i] == 0) {
      cout << i + 1 << " ";
    }
  }
  return 0;
}
