#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast", "-funroll-all-loops")
using namespace std;
const int N = 1e6 + 10;
int vis[N], cnt[N], n, m, a[N], len, res[N], b[N], mx, id, num;
signed main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
  sort(a + 1, a + 1 + n);
  len = unique(a + 1, a + 1 + n) - a - 1;
  for (int i = 1; i <= n; i++)
    if (b[i] <= 1e6) cnt[b[i]]++;
  for (int i = 1; i <= len && a[i] <= m; i++)
    for (int j = a[i]; j <= m; j += a[i]) res[j] += cnt[a[i]];
  for (int i = 1; i <= m; i++)
    if (res[i] > mx) mx = res[i], id = i;
  if (!mx) return puts("1 0"), 0;
  for (int i = 1; i <= n; i++)
    if (id % b[i] == 0) num++;
  cout << id << ' ' << num << '\n';
  for (int i = 1; i <= n; i++)
    if (id % b[i] == 0) printf("%d ", i);
  return 0;
}
