#include <bits/stdc++.h>
using namespace std;
void add(set<int> &a, set<int> &b) {
  for (set<int>::iterator it = b.begin(); it != b.end(); it++) {
    a.insert(*it);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, m, t;
  while (cin >> n >> m) {
    int to[1000005];
    memset(to, 0, 1000005 * sizeof(int));
    set<int> d;
    map<int, set<int>> dict;
    for (int i = 1; i <= n; i++) {
      cin >> t;
      if (t <= m) {
        dict[t].insert(i);
      }
    }
    for (map<int, set<int>>::iterator it = dict.begin(); it != dict.end();
         it++) {
      for (int i = 1; it->first * i <= m; i++) {
        to[it->first * i] += dict[it->first].size();
      }
    }
    int max = 0, num = 1;
    for (int i = 1; i <= m; i++) {
      if (to[i] > max) max = to[i], num = i;
    }
    for (map<int, set<int>>::iterator it = dict.begin(); it != dict.end();
         it++) {
      if (it->first <= num && num % it->first == 0) add(d, it->second);
    }
    cout << num << " " << d.size() << endl;
    for (set<int>::iterator it = d.begin(); it != d.end(); it++) {
      if (it != d.begin()) cout << " ";
      cout << *it;
    }
    cout << endl;
  }
  return 0;
}
