#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int a[maxn], cnt[maxn], tmp[maxn];
int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    if (a[i] <= m) cnt[a[i]]++;
  }
  for (int i = 1; i <= m; i++)
    for (int k = 1; k * i <= m; k++) tmp[k * i] += cnt[i];
  int M = -1, p;
  for (int i = 1; i <= m; i++)
    if (tmp[i] > M) M = tmp[i], p = i;
  printf("%d %d\n", p, M);
  for (int i = 1; i <= n; i++)
    if (p % a[i] == 0) printf("%d ", i);
  return 0;
}
