#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000100;
int a[MAXN];
int di[MAXN];
int c[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] <= m) {
      c[a[i]]++;
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j * i <= m; j++) {
      di[j * i] += c[i];
    }
  }
  int k = 0;
  int lcm = 1;
  for (int i = 1; i <= m; i++) {
    if (di[i] > k) {
      k = di[i];
      lcm = i;
    }
  }
  cout << lcm << ' ' << k << '\n';
  bool ok = false;
  if (k > 0) {
    for (int i = 0; i < n; i++) {
      if (lcm % a[i] == 0) {
        if (ok) {
          cout << ' ';
        }
        ok = true;
        cout << i + 1;
      }
    }
    cout << '\n';
  }
}
