#include <bits/stdc++.h>
const int MAXN = 1000000 + 100;
int a[MAXN], cnt[MAXN], num[MAXN];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    if (a[i] <= m) {
      ++cnt[a[i]];
    }
  }
  for (int i = 1; i <= m; ++i) {
    for (int j = i; j <= m; j += i) {
      num[j] += cnt[i];
    }
  }
  int k = 0, l = 1;
  for (int i = 1; i <= m; ++i) {
    if (num[i] > k) {
      l = i;
      k = num[i];
    }
  }
  printf("%d %d\n", l, k);
  for (int i = 1; i <= n; ++i) {
    if (l % a[i] == 0) {
      printf("%d ", i);
    }
  }
  puts("");
  return 0;
}
