#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int n, k, a[maxn], cnt[maxn], b[maxn], maxx;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] <= k) b[a[i]]++, maxx = max(maxx, a[i]);
  }
  for (int i = 1; i <= maxx; i++)
    for (int j = 1; j * i <= k; j++) cnt[i * j] += b[i];
  int ans = 1, maxt = cnt[1];
  for (int i = 1; i <= k; i++)
    if (cnt[i] > maxt) ans = i, maxt = cnt[i];
  printf("%d %d\n", ans, maxt);
  for (int i = 1; i <= n; i++)
    if (!(ans % a[i])) printf("%d ", i);
  return 0;
}
