#include <bits/stdc++.h>
const int maxn = 1e6 + 10;
using namespace std;
int n, m, cnt[maxn], ans = -1, id, A[maxn];
bool mark[maxn];
vector<int> p[maxn];
void sieve() {
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i) {
      p[j].push_back(i);
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  sieve();
  for (int i = 0; i < n; i++) {
    scanf("%d", A + i);
    if (A[i] <= m) {
      cnt[A[i]]++;
    }
  }
  for (int i = 1; i < m + 1; i++) {
    int a = 0;
    for (int j = 0; j < p[i].size(); j++) {
      int b = p[i][j];
      a += cnt[b];
    }
    if (a > ans) {
      id = i;
      ans = a;
    }
  }
  printf("%d %d\n", id, ans);
  for (int i = 0; i < n; i++) {
    if (id % A[i] == 0) {
      printf("%d ", i + 1);
    }
  }
  cout << endl;
}
