#include <bits/stdc++.h>
using namespace std;
int coun[1000005];
int a[1000005];
int cn[1000005];
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int i;
  int j;
  for (i = 0; i < n; i++) {
    cin >> j;
    if (j <= m) {
      coun[j]++;
    }
    a[i] = j;
  }
  int ans = 0;
  int d = 0;
  for (i = 1; i <= m; i++) {
    for (j = i; j <= m; j += i) {
      cn[j] += coun[i];
    }
  }
  for (i = m; i >= 1; i--) {
    if (ans < cn[i]) {
      ans = cn[i];
      d = i;
    } else if (ans == cn[i])
      d = i;
  }
  cout << d << " ";
  cout << ans << endl;
  for (i = 0; i < n; i++) {
    if (d % a[i] == 0) cout << i + 1 << " ";
  }
}
