#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e6 + 100;
pair<long long, long long> a[maxN];
long long cnt[maxN];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i].first;
  for (int i = 1; i <= n; ++i) a[i].second = i;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    if (i != 1 && a[i].first == a[i - 1].first) continue;
    if (a[i].first > m) break;
    int j = i;
    while (j <= n && a[i].first == a[j].first) ++j;
    --j;
    long long cur = 1;
    while (a[i].first * cur <= m) {
      cnt[a[i].first * cur] += (j - i + 1);
      ++cur;
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    if (cnt[i] > cnt[ans]) ans = i;
  }
  if (ans == 0) {
    cout << 1 << " " << 0 << endl;
    return 0;
  }
  vector<long long> answer;
  for (int i = 1; i <= n; ++i) {
    if (ans % a[i].first == 0) answer.push_back(a[i].second);
  }
  sort(answer.begin(), answer.end());
  cout << ans << " " << answer.size() << endl;
  for (int i = 0; i < answer.size(); ++i) cout << answer[i] << " ";
  cout << endl;
  return 0;
}
