#include <bits/stdc++.h>
using namespace std;
int arr[1000000 + 5] = {};
int num[1000000 + 5] = {};
int k[1000000 + 5] = {};
int main() {
  int len, kmax, iter, j, most, l;
  cin >> len >> kmax;
  if (len == 0) {
    cout << 1 << ' ' << 0;
    return 0;
  }
  for (iter = 0; iter < len; iter++) {
    scanf("%d", &arr[iter]);
    if (arr[iter] > kmax)
      continue;
    else
      num[arr[iter]]++;
  }
  for (iter = 1; iter <= kmax; iter++) {
    for (j = iter; j <= kmax; j += iter) k[j] += num[iter];
  }
  most = k[1];
  l = 1;
  for (iter = 1; iter <= kmax; iter++) {
    if (k[iter] > most) {
      most = k[iter];
      l = iter;
    }
  }
  cout << l << ' ' << most << endl;
  for (iter = 0; iter < len; iter++) {
    if (l % arr[iter] == 0) cout << iter + 1 << ' ';
  }
  return 0;
}
