#include <bits/stdc++.h>
using namespace std;
int cnt[1000005] = {0}, incnt[1000005] = {0}, vec[1000005];
int main() {
  int n, m, maxlcm = 1, maxcnt = 0;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &vec[i]);
    if (vec[i] <= m) {
      incnt[vec[i]]++;
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i) {
      cnt[j] += incnt[i];
    }
    if (cnt[i] > maxcnt) {
      maxcnt = cnt[i];
      maxlcm = i;
    }
  }
  printf("%d %d\n", maxlcm, maxcnt);
  for (int i = 1; i <= n; i++) {
    if (maxlcm % vec[i] == 0) {
      printf("%d ", i);
    }
  }
  return 0;
}
