#include <bits/stdc++.h>
using namespace std;
struct lookup {
  int k;
  vector<int> vec;
  lookup() { k = 0; }
};
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n];
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    mp[arr[i]]++;
  }
  lookup look[m + 3];
  for (int i = 1; i <= m; i++) {
    if (mp.find(i) == mp.end()) continue;
    int count = mp[i];
    for (int k = 1; i * k <= m; k++) {
      look[i * k].k += count;
      look[i * k].vec.push_back(i);
    }
  }
  int l = 1, k = 0;
  for (int i = 1; i <= m; i++)
    if (look[i].k > k) {
      k = look[i].k;
      l = i;
    }
  cout << l << " " << look[l].k << "\n";
  set<int> s;
  for (int j : look[l].vec) s.insert(j);
  for (int i = 0; i < n; i++) {
    if (s.find(arr[i]) != s.end()) printf("%d ", i + 1);
  }
}
