#include <bits/stdc++.h>
using namespace std;
int cnt[1000000 + 10];
int a[1000000 + 10];
int main() {
  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 = m; i >= 1; i--) {
    for (int j = i; (j += i) <= m;) {
      cnt[j] += cnt[i];
    }
  }
  int i, j;
  for (i = j = 1; i <= m; i++) {
    if (cnt[i] > cnt[j]) {
      j = i;
    }
  }
  cout << j << " " << cnt[j] << endl;
  for (i = 0; i < n; i++) {
    if (j % a[i] == 0) {
      cout << i + 1 << " ";
    }
  }
  return 0;
}
