#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1000005];
int cnt[1000005];
int num[1000005];
void init() {
  for (int i = 1; i <= n; i++) {
    if (a[i] > 1000000) continue;
    cnt[a[i]]++;
  }
  for (int i = 1; i <= 1000000; i++) {
    if (cnt[i]) {
      for (int j = i; j <= m; j += i) {
        num[j] += cnt[i];
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  init();
  int Max = 0;
  int lcm = 1;
  for (int i = 1; i <= m; i++) {
    if (num[i] > Max) {
      Max = num[i];
      lcm = i;
    }
  }
  vector<int> pos;
  for (int i = 1; i <= n; i++) {
    if (lcm % a[i] == 0) pos.push_back(i);
  }
  printf("%d %d\n", lcm, pos.size());
  for (int i = 0; i < pos.size(); i++) {
    printf("%d", pos[i]);
    if (i == pos.size() - 1)
      printf("\n");
    else
      printf(" ");
  }
  return 0;
}
