#include <bits/stdc++.h>
using namespace std;
int elems[1000001];
int used[1000001];
int resp[1000001];
void longestSubsecuence() {
  int maxsec = 0;
  int n, m;
  n = 6;
  m = 4;
  scanf("%d %d\n", &n, &m);
  for (int i = 0; i < n; i++) {
    int val;
    scanf("%d", &val);
    elems[i] = val;
    if (val <= m && val > 0) {
      used[val]++;
    }
  }
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j += i) {
      resp[j] += used[i];
    }
  int c = 0;
  int lcm = 1;
  for (int i = 0; i <= m; i++) {
    if (resp[i] > c) {
      lcm = i;
      c = resp[i];
    }
  }
  printf("%d %d\n", lcm, c);
  if (c == 0) return;
  for (int i = 0; i < n; i++)
    if (lcm % elems[i] == 0) cout << i + 1 << " ";
}
int main(int argc, char *argv[]) {
  longestSubsecuence();
  return 0;
}
