#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 10;
int n, k, a[N], f[N], c[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i)
    if (a[i] <= k) c[a[i]]++;
  for (int i = 1; i <= k; ++i)
    for (int j = i; j <= k; j += i) f[j] += c[i];
  int ans = 0;
  for (int i = 1; i <= k; ++i) ans = max(ans, f[i]);
  for (int t = 1; t <= k; ++t)
    if (ans == f[t]) {
      printf("%d %d\n", t, f[t]);
      for (int i = 1; i <= n; ++i)
        if (t % a[i] == 0) printf("%d ", i);
      return 0;
    }
  return 0;
}
