#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int n, m;
int f[N + 2], dp[N + 2], ans, x, lCm, v[N + 2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    x = v[i];
    if (x <= m) f[x]++;
  }
  lCm = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i) dp[j] += f[i];
    if (ans < dp[i]) {
      ans = dp[i];
      lCm = i;
    }
  }
  cout << lCm << " " << ans << "\n";
  for (int i = 1; i <= n; i++)
    if (lCm % v[i] == 0) cout << i << " ";
  return 0;
}
