#include <bits/stdc++.h>
using namespace std;
int a[1000100], vis[1000100], dp[1000100];
vector<int> res;
int solve(int n) {
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      dp[j] += vis[i];
    }
  }
  int res = 0, ma = 0;
  for (int i = 1; i <= n; i++) {
    if (dp[i] > ma) {
      ma = dp[i];
      res = i;
    }
  }
  return res;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] <= m) vis[a[i]]++;
  }
  int x = solve(m);
  if (x == 0) {
    printf("%d %d\n", 1, 0);
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (x % a[i] == 0) res.push_back(i + 1);
  }
  printf("%d %d\n", x, res.size());
  for (int i = 0; i < res.size(); i++) printf("%d ", res[i]);
  printf("\n");
  return 0;
}
