#include <bits/stdc++.h>
using namespace std;
const int max_n = 1001100;
int cnt[max_n];
int num[max_n];
int ans[max_n];
int main() {
  int n, m;
  int x;
  int sum = 0;
  int qsum = 1;
  scanf("%d%d", &n, &m);
  memset(cnt, 0, sizeof(cnt));
  memset(ans, 0, sizeof(ans));
  for (int i = 0; i < n; ++i) {
    scanf("%d", &num[i]);
    if (num[i] > m) continue;
    ++cnt[num[i]];
  }
  for (int i = 1; i <= m; ++i) {
    if (!cnt[i]) continue;
    for (int j = i; j <= m; j += i) {
      ans[j] += cnt[i];
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (ans[i] > sum) {
      sum = ans[i];
      qsum = i;
    }
  }
  printf("%d %d\n", qsum, sum);
  for (int i = 0; i < n; ++i)
    if (qsum % num[i] == 0) printf("%d ", i + 1);
  return 0;
}
