#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& num) {
  num = 0;
  bool f = true;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = false;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    num = num * 10 + ch - '0';
    ch = getchar();
  }
  num = f ? num : -num;
}
int out[100];
template <class T>
inline void write(T x, char ch) {
  if (x == 0) {
    putchar('0');
    putchar(ch);
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int num = 0;
  while (x) {
    out[num++] = (x % 10);
    x = x / 10;
  }
  for (int i = (num - 1); i >= (0); i--) putchar(out[i] + '0');
  putchar(ch);
}
const double eps = 1e-8;
int a[1000005], num[1000005], ans[1000005];
int n, m, Max, ord;
int main() {
  read(n);
  read(m);
  for (int i = (1); i <= (n); i++) {
    read(a[i]);
    if (a[i] <= m) num[a[i]]++;
  }
  for (int i = (1); i <= (m); i++) {
    for (int j = i; j <= m; j += i) ans[j] += num[i];
  }
  for (int i = (1); i <= (m); i++)
    if (ans[i] > Max) Max = ans[i], ord = i;
  if (ord == 0) {
    write(1, ' ');
    puts("0");
    return 0;
  }
  write(ord, ' ');
  write(Max, '\n');
  for (int i = (1); i <= (n); i++)
    if (ord % a[i] == 0) write(i, ' ');
}
