#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, x;
  cin >> n >> m;
  vector<long long> lookup(1000001);
  vector<long long> jarvis(m + 1);
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &x);
    v[i] = x;
    if (x <= m) lookup[x]++;
  }
  for (long long i = 1; i <= m; i++) {
    for (long long j = i; j <= m; j += i) {
      jarvis[j] += lookup[i];
    }
  }
  long long ans = -1, val = 0;
  for (long long i = 1; i <= m; i++)
    if (jarvis[i] > ans) ans = jarvis[i], val = i;
  cout << val << " " << jarvis[val] << endl;
  for (long long i = 0; i < n; i++)
    if (val % v[i] == 0) cout << i + 1 << " ";
  return 0;
}
