#include <bits/stdc++.h>
using namespace std;
const int N = 1001000;
int ans(1);
int a[N], b[N], c[N];
int main() {
  int n, m;
  register int i;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] <= m) b[a[i]]++;
  }
  for (i = 1; i <= m; ++i) {
    for (int p(i); p <= m; p += i) c[p] += b[i];
  }
  for (i = 1; i <= m; ++i)
    if (c[i] > c[ans]) ans = i;
  printf("%d %d\n", ans, c[ans]);
  for (i = 1; i <= n; ++i)
    if (!(ans % a[i])) printf("%d ", i);
  return 0;
}
