#include <bits/stdc++.h>
int n, m, p, q, x[1000005], y[1000005], a, b;
int main() {
  scanf("%d%d", &n, &m);
  for (a = 1; a <= n; a++) {
    scanf("%d", &x[a]);
    if (x[a] <= m) y[x[a]]++;
  }
  for (a = m; a; a--)
    for (b = a * 2; b <= m; b += a) y[b] += y[a];
  for (a = 1; a <= m; a++)
    if (y[a] > q) p = a, q = y[a];
  if (q) {
    printf("%d %d\n", p, q);
    for (a = 1; a <= n; a++)
      if (p % x[a] == 0) printf("%d ", a);
  } else
    printf("1 0\n\n");
}
