#include <bits/stdc++.h>
using namespace std;
long int val[1000001];
int stat[1000001];
long int cnt[1000001], tot[1000001];
long int gcd(long int x, long int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long int lcm(long int x, long int y) {
  long long int temp = (long long int)x * (long long int)y;
  long int temp1 = gcd(x, y);
  temp /= temp1;
  return temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long int n, m;
  cin >> n >> m;
  for (long int i = 1; i <= n; ++i) {
    cin >> val[i];
    if (val[i] <= m) cnt[val[i]]++;
  }
  for (long int i = 1; i <= m; ++i) {
    for (long int j = i; j <= m; j += i) tot[j] += cnt[i];
  }
  long int ans = 0, ans1;
  for (long int i = 1; i <= m; ++i) {
    if (ans < tot[i]) {
      ans = tot[i];
      ans1 = i;
    }
  }
  long int res = 1;
  for (long int i = 1; i <= ans1; ++i) {
    if ((ans1 % i) == 0 && cnt[i] > 0) {
      stat[i] = 1;
      res = lcm(res, i);
    }
  }
  cout << res << " " << ans << "\n";
  for (long int i = 1; i <= n; ++i) {
    if (val[i] > m) continue;
    if (stat[val[i]] == 1) cout << i << " ";
  }
  return 0;
}
