#include <bits/stdc++.h>
const int MAXN = 1e6 + 10;
int n, m;
int inp[MAXN], cnt[MAXN], mul[MAXN], ansl, ansk = 1;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", inp + i);
    if (inp[i] <= m) {
      cnt[inp[i]]++;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (cnt[i] > 0) {
      for (int j = i; j <= m; j += i) {
        mul[j] += cnt[i];
      }
    }
  }
  for (int k = 1; k <= m; k++) {
    if (mul[k] > ansl) {
      ansl = mul[k];
      ansk = k;
    }
  }
  printf("%d %d\n", ansk, ansl);
  for (int i = 1; i <= n; i++) {
    if (ansk % inp[i] == 0) {
      printf("%d ", i);
    }
  }
  return 0;
}
