#include <bits/stdc++.h>
const int MAXN = 1000001;
int n, m, a[MAXN], b[MAXN];
int box[MAXN], axi[MAXN];
int n1, n2;
int main() {
  std::cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    std::scanf("%d", a + i);
    if (a[i] <= m) {
      b[++n1] = a[i];
      box[a[i]]++;
    }
  }
  if (!n1) {
    std::puts("1 0");
    return 0;
  }
  std::sort(b + 1, b + 1 + n1);
  int n2 = std::unique(b + 1, b + 1 + n1) - b - 1;
  for (int i = 1; i <= n2; i++)
    for (int j = 1; j <= m / b[i]; j++) axi[b[i] * j] += box[b[i]];
  int sum = 0, lcm;
  for (int i = 1; i <= m; i++) {
    if (axi[i] > sum) sum = axi[i], lcm = i;
  }
  std::printf("%d %d\n", lcm, sum);
  for (int i = 1; i <= n; i++)
    if (!(lcm % a[i])) std::printf("%d ", i);
  std::putchar('\n');
  return 0;
}
