#include <bits/stdc++.h>
using namespace std;
long long a[1000011];
long long num[1000011];
long long b[1000011];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, tmp;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    b[i] = tmp;
    if (tmp <= m) a[tmp]++;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i) num[j] += a[i];
  }
  long long sum = 0, ans;
  for (int i = 1; i <= m; i++) {
    if (num[i] > sum) {
      ans = i;
      sum = num[i];
    }
  }
  if (sum == 0) {
    cout << "1 0";
    return 0;
  }
  cout << ans << " " << sum << endl;
  for (int i = 0; i < n; i++) {
    if (ans % b[i] == 0) cout << i + 1 << " ";
  }
}
