#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int c[MAXN], p[MAXN], a[MAXN];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < MAXN) c[a[i]]++;
  }
  int Max = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i) p[j] += c[i];
    if (p[i] > p[Max]) Max = i;
  }
  if (Max == 0) {
    cout << 1 << " " << 0 << endl;
    return 0;
  }
  cout << Max << " " << p[Max] << endl;
  for (int i = 0; i < n; i++)
    if (Max % a[i] == 0) cout << i + 1 << " ";
  cout << endl;
  return 0;
}
