#include <bits/stdc++.h>
int arr[1000001], res[2][1000001];
int main() {
  int n, m, max = 1;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i += 1) {
    int j = 1;
    scanf("%d", &arr[i]);
    if (arr[i] <= m) res[0][arr[i]] += 1;
  }
  for (int i = 1; i <= m; i += 1)
    if (res[0][i])
      for (int j = i; j <= m; j += i) res[1][j] += res[0][i];
  for (int i = 2; i <= m; i += 1)
    if (res[1][i] > res[1][max]) max = i;
  printf("%d %d\n", max, res[1][max]);
  for (int i = 0; i < n; i += 1)
    if (max % arr[i] == 0) printf("%d ", i + 1);
  return 0;
}
