#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int cnt[maxn], A[maxn], N, M, F[maxn];
int main() {
  scanf("%d%d", &N, &M);
  memset(cnt, 0, sizeof(cnt));
  memset(F, 0, sizeof(F));
  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 j = i; j <= M; j += i) {
      F[j] += cnt[i];
    }
  }
  int id = 1;
  for (int i = 1; i <= M; ++i) {
    if (F[i] > F[id]) id = i;
  }
  printf("%d %d\n", id, F[id]);
  for (int i = 1; i <= N; ++i) {
    if (id % A[i] == 0) printf("%d ", i);
  }
  puts("");
  return 0;
}
