#include <bits/stdc++.h>
using namespace std;
int tab[1000100] = {0};
int a[1000100], n, m;
vector<int> primes;
int vis[1000100] = {0};
int res[1000100] = {0};
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < n; ++i)
    if (a[i] <= m) tab[a[i]]++;
  int maximum = 0;
  int pos = 1;
  for (int i = 1; i <= m; ++i)
    for (int j = i; j <= m; j += i) res[j] += tab[i];
  for (int i = 1; i <= m; ++i) {
    if (maximum < res[i]) {
      maximum = res[i];
      pos = i;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i)
    if (pos % a[i] == 0) cnt++;
  cout << pos << " " << cnt << endl;
  for (int i = 0; i < n; ++i)
    if (pos % a[i] == 0) cout << i + 1 << " ";
  cout << endl;
  return 0;
}
