#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> inp(n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    inp[i] = a[i];
  }
  sort(a.begin(), a.end());
  vector<pair<int, int> > b;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (i == 0 || a[i] == a[i - 1]) {
      cnt++;
    } else {
      b.push_back({a[i - 1], cnt});
      cnt = 1;
    }
  }
  b.push_back({a[n - 1], cnt});
  vector<int> len(m + 1);
  int lcm = 1;
  for (auto i : b) {
    for (int j = i.first; j <= m; j += i.first) {
      len[j] += i.second;
      if (len[j] > len[lcm]) {
        lcm = j;
      }
    }
  }
  cout << lcm << ' ' << len[lcm] << "\n";
  for (int i = 0; i < n; ++i) {
    if (lcm % inp[i] == 0) {
      cout << i + 1 << ' ';
    }
  }
}
