#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
  for (Tp current = _begin; current != _end; ++current) {
    std::cout << *current << _delim;
  }
  std::cout << '\n';
}
using ll = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);
int arr[1000000];
int cnt[1000001];
int klcm[1000001];
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (n); ++i) {
    cin >> arr[i];
    if (arr[i] <= m) {
      ++cnt[arr[i]];
    }
  }
  for (int i = 0; i < (m + 1); ++i) {
    if (cnt[i] > 0) {
      for (int d = i; d <= m; d += i) {
        klcm[d] += cnt[i];
      }
    }
  }
  int ansK = 0;
  int ansL = 1;
  for (int i = 0; i < (m + 1); ++i) {
    if (klcm[i] > ansK) {
      ansK = klcm[i];
      ansL = i;
    }
  }
  cout << ansL << ' ' << ansK << "\n";
  for (int i = 0; i < (n); ++i) {
    if (ansK == 0) {
      break;
    }
    if (ansL % arr[i] == 0) {
      --ansK;
      cout << i + 1 << ' ';
    }
  }
  cout << "\n";
  return 0;
}
