#include <bits/stdc++.h>
using namespace std;
int n, m, a[1001000], cnt[1001000], z[1001000];
int main() {
  ios::sync_with_stdio(false);
  memset(cnt, 0, sizeof(cnt));
  memset(z, 0, sizeof(z));
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] <= m) cnt[a[i]]++;
  }
  int ans = 0, flag = 0;
  for (int i = 1; i <= m; i++) {
    if (cnt[i]) {
      for (int k = 1; k * i <= m; k++) z[k * i] += cnt[i];
    }
  }
  for (int i = 1; i <= m; i++) {
    if (z[i] > ans) {
      ans = z[i];
      flag = i;
    }
  }
  cout << (flag == 0 ? 1 : flag) << " " << ans << endl;
  for (int i = 1; i <= n; i++) {
    if (flag % a[i] == 0 && flag != 0) cout << i << " ";
  }
  cout << endl;
  return 0;
}
