#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n), cnt(m + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] <= m) {
      cnt[a[i]] += 1;
    }
  }
  for (int i = m; i >= 1; --i) {
    for (int j = i + i; j <= m; j += i) {
      cnt[j] += cnt[i];
    }
  }
  int k = -1, mx = 0;
  for (int i = m; i >= 1; --i) {
    if (cnt[i] >= mx) {
      k = i;
      mx = cnt[i];
    }
  }
  cout << k << ' ' << mx << '\n';
  for (int i = 0; i < n; ++i) {
    if (k % a[i] == 0) {
      cout << i + 1 << ' ';
    }
  }
  cout << '\n';
}
