#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1E9 + 7, INF = 2E18 + 5;
const double PI = 2 * acos(0.0);
const long double EPS = 1.0E-14;
long long arr[1000005], arrFreq[1000005], arrAns[1000005];
vector<long long> vec;
int main() {
  long long n, m, lcm = 1, sz = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    if (arr[i] <= m) {
      arrFreq[arr[i]]++;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (!arrFreq[i]) continue;
    for (int j = i; j <= m; j += i) {
      arrAns[j] += arrFreq[i];
    }
  }
  for (int i = 1; i <= m; i++) {
    if (arrAns[i] > sz) {
      sz = arrAns[i];
      lcm = i;
    }
  }
  for (int i = 0; i < n; i++) {
    if (lcm % arr[i] == 0) {
      vec.push_back(i + 1);
    }
  }
  cout << lcm << " " << vec.size() << "\n";
  for (int i = 0; i < vec.size(); i++) {
    printf("%lld ", vec[i]);
  }
  return 0;
}
