#include <bits/stdc++.h>
typedef long long LL;
const double INF = 1e100;
const int oo = ~0u >> 2;
const double pi = acos(-1.0);
const double EPS = 1e-8;
const int MAXN = 1000033;
int n, m;
int a[MAXN], b[MAXN], c[MAXN];
int r1, r2;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1), __ = (n); i <= __; ++i) {
    scanf("%d", a + i);
    if (a[i] <= m) ++b[a[i]];
  }
  for (int i = (1), __ = (m); i <= __; ++i) {
    for (int j = i; j <= m; j += i) c[j] += b[i];
  }
  r1 = 1;
  for (int i = (1), __ = (m); i <= __; ++i) {
    if (c[i] > r2) {
      r1 = i;
      r2 = c[i];
    }
  }
  printf("%d %d\n", r1, r2);
  for (int i = (1), __ = (n); i <= __; ++i)
    if (r1 % a[i] == 0) printf("%d ", i);
  return 0;
}
