#include <bits/stdc++.h>
using namespace std;
int factorcount[1000016];
int a[1000016];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] <= m) factorcount[a[i]]++;
  }
  for (int i = m; i >= 1; i--) {
    for (int j = i << 1; j <= m; j += i) {
      factorcount[j] += factorcount[i];
    }
  }
  int l = 1, k = 0;
  for (int i = 1; i <= m; i++) {
    if (factorcount[i] > k) k = factorcount[i], l = i;
  }
  cout << l << ' ' << k << endl;
  for (int i = 0; i < n; i++)
    if (l % a[i] == 0) cout << i + 1 << ' ';
  return 0;
}
