#include <bits/stdc++.h>
using namespace std;
char buf[1 << 20], *p1, *p2;
template <typename T>
inline void read(T &t) {
  register int v =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
           ? EOF
           : *p1++);
  T f = 1;
  t = 0;
  while (!isdigit(v)) {
    if (v == '-') f = -1;
    v = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  while (isdigit(v)) {
    t = t * 10 + v - 48;
    v = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  t *= f;
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}
const int N = 1e6 + 10;
int cnt[N], ans[N], n, m, a[N];
bool vis[N];
signed main() {
  read(n, m);
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
    if (a[i] <= m) cnt[a[i]]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (a[i] > m) continue;
    if (!vis[a[i]] && a[i] <= m) {
      for (int j = 1; a[i] * j <= m; ++j) {
        ans[a[i] * j] += cnt[a[i]];
      }
      vis[a[i]] = 1;
    }
  }
  int now = 0, lcm = 1;
  for (int i = 1; i <= m; ++i) {
    if (ans[i] > now) {
      now = ans[i], lcm = i;
    }
  }
  printf("%d %d\n", lcm, now);
  for (int i = 1; i <= n; ++i) {
    if (lcm % a[i] == 0) printf("%d ", i);
  }
  return 0;
}
