#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[1000003];
int ans[1000003];
set<int> s;
int main() {
  int res = 0, b = 1;
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0, x; i < n; i++) {
    scanf("%d", &x);
    if (x <= m) cnt[x].push_back(i + 1);
  }
  for (int i = 1; i <= m; i++) {
    if (cnt[i].size())
      for (int j = 1; j * i <= m; j++) ans[j * i] += cnt[i].size();
    if (ans[i] > res) {
      res = ans[i];
      b = i;
    }
  }
  printf("%d %d\n", b, res);
  for (int i = 1; i <= m; i++)
    if (cnt[i].size() && b % i == 0)
      for (int j = 0; j < cnt[i].size(); j++) s.insert(cnt[i][j]);
  for (set<int>::iterator it = s.begin(); it != s.end(); it++)
    printf("%d ", *it);
  puts("");
  return 0;
}
