#include <bits/stdc++.h>
using namespace std;
int dp[1000001];
int a[1000001];
vector<int> v[1000001];
vector<int> an;
int main() {
  memset((dp), (0), sizeof(dp));
  memset((a), (0), sizeof(a));
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x <= m) {
      a[x]++;
      v[x].push_back(i + 1);
    }
  }
  for (int i = 1; i <= m; i++) {
    int x = i;
    while (x <= m) {
      dp[x] += a[i];
      x += i;
    }
  }
  int ans = -1, ind = -1;
  for (int i = 1; i < 1000001; i++)
    if (ans < dp[i]) ans = dp[i], ind = i;
  printf("%d", ind);
  printf(" ");
  printf("%d", dp[ind]);
  printf("\n");
  for (int i = 1; i <= m; i++)
    if (ind % i == 0 && a[i] > 0)
      for (int j : v[i]) an.push_back(j);
  sort(an.begin(), an.end());
  for (int i : an) printf("%d", i), printf(" ");
  printf("\n");
}
