#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int N, M;
int a[1000000];
int cnt[1000001];
int x[1000001];
int main(void) {
  cin >> N >> M;
  for (int i = 0; i < (int)(N); ++i) {
    scanf("%d", a + i);
    if (a[i] <= M + 1) cnt[a[i]]++;
  }
  for (int i = 1; i < (int)(M + 1); ++i)
    if (cnt[i])
      for (int j = i; j <= M; j += i) x[j] += cnt[i];
  int mx = -1, l = -1;
  for (int i = 1; i < (int)(M + 1); ++i) mx = max(mx, x[i]);
  for (int i = 1; i < (int)(M + 1); ++i)
    if (x[i] == mx) {
      l = i;
      break;
    }
  cout << l << " " << x[l] << endl;
  for (int i = 0; i < (int)(N); ++i)
    if (l % a[i] == 0) cout << i + 1 << " ";
  cout << endl;
  return 0;
}
