#include <bits/stdc++.h>
using namespace std;
int n, m, ans, cnt[1000006], lcm, lis[1000006], mul[1000006];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> lis[i];
    if (lis[i] < 1000006) cnt[lis[i]]++;
  }
  ans = 0;
  for (int i = 1; i < m + 1; i++)
    if (cnt[i]) {
      for (int j = i; j <= m; j += i) mul[j] += cnt[i];
    }
  for (int j = 1; j < m + 1; j++) {
    if (ans < mul[j]) {
      ans = mul[j];
      lcm = j;
    }
  }
  if (ans == 0) {
    cout << "1 0\n";
    return 0;
  }
  cout << lcm << ' ' << ans << endl;
  for (int i = 0; i < n; i++)
    if (lcm % lis[i] == 0) cout << i + 1 << ' ';
}
