#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int a[N], num[N], b[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    b[i] = x;
    if (x > m) continue;
    num[x]++;
  }
  memcpy(a, num, sizeof num);
  for (int i = m; i > 0; i--) {
    for (int j = i + i; j <= m; j += i) a[j] += num[i];
  }
  auto lcm = max_element(a, a + N);
  if (*lcm == 0) {
    cout << 1 << " " << 0 << endl;
    return 0;
  }
  cout << lcm - a << " " << *lcm << endl;
  for (int i = 0; i < n; i++)
    if ((lcm - a) % b[i] == 0) cout << i + 1 << " ";
  cout << endl;
  return 0;
}
