#include<bits/stdc++.h>
using namespace std;
int a[1000007],mul[1000007],cal[1000007];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
//    memset(mul,0,sizeof mul);
//    memset(cal,0,sizeof cal);
    vector<int>v;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>m)continue;
        cal[a[i]]++;
    }
    int mx=0,lcm=1;
    for(int i=1;i<=m;i++){
        if(cal[i]){
            for(int j=i;j<=m;j+=i){
                mul[j]+=cal[i];
            }
        }
    }
    for(int j=1;j<=m;j++){
        if(mx<mul[j]){
            mx=mul[j];
            lcm=j;
        }
    }
    printf("%d %d\n",lcm,mx);
    for(int i=0;i<n;i++){
        if(lcm%a[i]==0)printf("%d ",i+1);
    }

//    for(int i=0;i<v.size();i++){
//        cout<<v[i]<<" ";
//    }
}


#include<bits/stdc++.h>
using namespace std;
int a[1000007],mul[1000007],cal[1000007];
int main()
{
    int n,m;
    cin>>n>>m;

//    memset(mul,0,sizeof mul);
//    memset(cal,0,sizeof cal);

    vector<int>v;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>m)continue;
        cal[a[i]]++;
    }
    int mx=0,lcm=1;
    for(int i=1;i<=m;i++){

        if(cal[i]){
            for(int j=i;j<=m;j+=i){
                mul[j]+=cal[i];

            }
        }
    }
    for(int j=1;j<=m;j++){
        if(mx<mul[j]){mx=mul[j];lcm=j;}
    }
    for(int i=0;i<n;i++){
        if(lcm%a[i]==0)v.push_back(i+1);
    }
    cout<<lcm<<" "<<v.size()<<endl;
    for(int i=0;i<v.size();i++){
        cout<<v[i]<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a[n],mul[m+1],cal[m+1];
    memset(mul,0,sizeof mul);
    memset(cal,0,sizeof cal);

    vector<int>v;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>m)continue;
        cal[a[i]]++;
    }
    int mx=0,lcm=1;
    for(int i=1;i<=m;i++){

        if(cal[i]){
            for(int j=i;j<=m;j+=i){
                mul[j]+=cal[i];

            }
        }
    }
    for(int j=1;j<=m;j++){
        if(mx<mul[j]){mx=mul[j];lcm=j;}
    }
    for(int i=0;i<n;i++){
        if(lcm%a[i]==0)v.push_back(i+1);
    }
    cout<<lcm<<" "<<v.size()<<endl;
    for(int i=0;i<v.size();i++){
        cout<<v[i]<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
int a[1000007],mul[1000007],cal[1000007];
int main()
{
    int n,m;
    cin>>n>>m;
//    memset(mul,0,sizeof mul);
//    memset(cal,0,sizeof cal);
    vector<int>v;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>m)continue;
        cal[a[i]]++;
    }
    int mx=0,lcm=1;
    for(int i=1;i<=m;i++){
        if(cal[i]){
            for(int j=i;j<=m;j+=i){
                mul[j]+=cal[i];
            }
        }
    }
    for(int j=1;j<=m;j++){
        if(mx<mul[j]){
            mx=mul[j];
            lcm=j;
        }
    }
    cout<<lcm<<" "<<mx<<endl;
    for(int i=0;i<n;i++){
        if(lcm%a[i]==0)cout<<i+1<<" ";
    }

//    for(int i=0;i<v.size();i++){
//        cout<<v[i]<<" ";
//    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a[n],mul[m+1];
    memset(mul,0,sizeof mul);
    map<int,int>mp;
    vector<int>v;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>m)continue;
        mp[a[i]]++;
    }
    int mx=0,lcm=1;
    for(int i=1;i<=m;i++){

        if(mp[i]){
            for(int j=i;j<=m;j+=i){
                mul[j]+=mp[i];

            }
        }
    }
    for(int j=1;j<=m;j++){
        if(mx<mul[j]){mx=mul[j];lcm=j;}
    }
    for(int i=0;i<n;i++){
        if(lcm%a[i]==0)v.push_back(i+1);
    }
    cout<<lcm<<" "<<v.size()<<endl;
    for(int i=0;i<v.size();i++){
        cout<<v[i]<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a[n],mul[m+1];
    memset(mul,0,sizeof mul);
    map<int,int>mp;
    vector<int>v;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>m)continue;
        mp[a[i]]++;
    }
    int mx=0,lcm=1;
    for(int i=1;i<=m;i++){
        for(int j=i;j<=m;j+=i){
            mul[j]+=mp[i];

        }
    }
    for(int j=1;j<=m;j++){
        if(mx<mul[j]){mx=mul[j];lcm=j;}
    }
    for(int i=0;i<n;i++){
        if(lcm%a[i]==0)v.push_back(i+1);
    }
    cout<<lcm<<" "<<v.size()<<endl;
    for(int i=0;i<v.size();i++){
        cout<<v[i]<<" ";
    }
}


#include <bits/stdc++.h>

#define endl "\n"
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

constexpr int N = 1e6 + 5;

int mp[N], n, m;
int cnt[N];
vector<int> vec;

void Solve() {
  cin >> n >> m;
  for (int i = 0, v; i < n; i++) {
    cin >> v;
    vec.push_back(v);
    if (v <= m)
      mp[v]++;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i)
      cnt[j] += mp[i];
  }
  auto it = max_element(cnt, cnt + N);
  int id = distance(cnt, it);
  cout << id << " " << *it << endl;
  for (int i = 0; i < n; i++) {
    if (id % vec[i] == 0)
      cout << i + 1 << " ";
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  // int t;
  // cin >> t;
  // while(t--)
  //auto start = chrono::high_resolution_clock::now();
    Solve();
  // auto end = chrono::high_resolution_clock::now();
  // cout << endl << (chrono::duration_cast<chrono::duration<double>>(end - start)).count();
  return 0;
}


#include <bits/stdc++.h>

#define endl "\n"
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

constexpr int N = 1e6 + 5;

int mp[N], n, m;
int cnt[N];
vector<int> vec;

void Solve() {
  cin >> n >> m;
  for (int i = 0, v; i < n; i++) {
    cin >> v;
    vec.push_back(v);
    if (v <= m)
      mp[v]++;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i)
      cnt[j] += mp[i];
  }
  auto it = max_element(cnt, cnt + N);
  int id = distance(cnt, it);
  if (*it == 0) {
    cout << 1 << " " << 0;
    return;
  }
  cout << id << " " << *it << endl;
  for (int i = 0; i < n; i++) {
    if (id % vec[i] == 0)
      cout << i + 1 << " ";
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  // int t;
  // cin >> t;
  // while(t--)
  //auto start = chrono::high_resolution_clock::now();
    Solve();
  // auto end = chrono::high_resolution_clock::now();
  // cout << endl << (chrono::duration_cast<chrono::duration<double>>(end - start)).count();
  return 0;
}


#include <bits/stdc++.h>

#define endl "\n"
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

constexpr int N = 1e6 + 5;

int mp[N], n, m;
int cnt[N];
vector<int> vec;

void Solve() {
  cin >> n >> m;
  for (int i = 0, v; i < n; i++) {
    cin >> v;
    vec.push_back(v);
    if (v <= m)
      mp[v]++;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = i; j <= m; j += i)
      cnt[j] += mp[i];
  }
  auto it = max_element(cnt, cnt + N);
  int id = distance(cnt, it);
  if (id == 0) {
    cout << 1 << " " << 0;
    return;
  }
  cout << id << " " << *it << endl;
  for (int i = 0; i < n; i++) {
    if (id % vec[i] == 0)
      cout << i + 1 << " ";
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  // int t;
  // cin >> t;
  // while(t--)
  //auto start = chrono::high_resolution_clock::now();
    Solve();
  // auto end = chrono::high_resolution_clock::now();
  // cout << endl << (chrono::duration_cast<chrono::duration<double>>(end - start)).count();
  return 0;
}


/* Manish Pant - insider_pants, hello_my_friend */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; }

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int n, m;
vector<pii> v;

void solve()
{
    sort(v.begin(), v.end());
    while(!v.empty() && v.back().F > m) v.pop_back();

    if(v.empty())
    {
        cout<<0<<' '<<0<<endl;
        return;
    }

    map<int, vector<int>> m;
    for(auto i:v) m[i.F].pb(i.S);

    int mx = 0;
    int idx = -1;
    for(int i = 0; i < v.size(); i++)
    {
        set<int> s;
        int num = v[i].F * (::m / v[i].F);
        for(int j = 1; j * j <= num; j++)
        {
            if(num % j == 0)
            {
                s.insert(j);
                s.insert(num / j);
            }
        }

        int t = 0;
        for(auto &j: s) t += int(m[j].size());

        if(t > mx)
        {
            mx = t;
            idx = i;
        }
    }

    vector<int> ans;
    int lcm = v[idx].F * (::m / v[idx].F);
    set<int> s;
    for(int j = 1; j * j <= lcm; j++)
    {
        if(lcm % j == 0)
        {
            s.insert(j);
            s.insert(lcm / j);
        }
    }

    lcm = 1;
    for(auto &i: s)
    {
        if(m[i].empty()) continue;
        for(auto j:m[i]) ans.pb(j);

        int val = i;
        int gcd = __gcd(i, lcm);
        lcm *= val;
        lcm /= gcd;
    }
    sort(ans.begin(), ans.end());

    cout<<lcm<<" "<<mx<<endl;
    for(int i:ans) cout<<i + 1<<' ';
    cout<<endl;
}

int main()
{
    fast();
    cin>>n>>m;
    for(int i = 0; i < n; i++)
    {
        ll a; cin>>a;
        v.pb(make_pair(a, i));
    }
    solve();
}


/* Manish Pant - insider_pants, hello_my_friend */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; }

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int N = 1e6 + 5;
int n, m;
vector<pll> v, v2;
vector<ll> cnt(N);

void solve()
{
    v2 = v;
    sort(v.begin(), v.end());
    while(!v.empty() && v.back().F > m) v.pop_back();

    if(v.empty())
    {
        cout<<1<<' '<<0<<endl;
        return;
    }

    map<ll, int> mp;
    for(int i = 0; i < v.size(); i++) mp[v[i].F]++;

    for(ll i = 1; i <= m; i++)
    {
        for(ll j = i; j <= m; j += i)
        {
            cnt[j] += mp[i];
        }
    }

    ll mx = 0, lcm = -1;
    for(int i = 1; i <= m; i++)
    {
        if(cnt[i] > mx)
        {
            mx = cnt[i];
            lcm = i;
        }
    }

    vector<int> ans;
    for(int i = 0; i < v.size(); i++)
    {
        if(lcm % v[i].F == 0)
        {
            ans.pb(v[i].S);
        }
    }

    sort(ans.begin(), ans.end());

    cout<<lcm<<' '<<int(ans.size())<<endl;
    for(int i:ans) cout<<i + 1<<' ';
    cout<<endl;
}

int main()
{
    fast();
    cin>>n>>m;
    for(int i = 0; i < n; i++)
    {
        ll a; cin>>a;
        v.pb(make_pair(a, i));
    }
    solve();
}


/* Manish Pant - insider_pants, hello_my_friend */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back
#define int long long

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; }

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int n, m;
vector<pii> v, v2;

void solve()
{
    v2 = v;
    sort(v.begin(), v.end());
    while(!v.empty() && v.back().F > m) v.pop_back();

    if(v.empty())
    {
        cout<<1<<' '<<0<<endl;
        return;
    }

    map<int, vector<int>> m;
    for(auto i:v) m[i.F].pb(i.S);

    int mx = 0;
    int idx = -1;
    for(int i = 0; i < v.size(); i++)
    {
        set<int> s;
        int num = v[i].F * (::m / v[i].F);
        for(int j = 1; j * j <= num; j++)
        {
            if(num % j == 0)
            {
                s.insert(j);
                s.insert(num / j);
            }
        }

        int t = 0;
        for(auto &j: s) t += ll(m[j].size());

        if(t > mx)
        {
            mx = t;
            idx = i;
        }
    }

    vector<int> ans;
    int lcm = v[idx].F * (::m / v[idx].F);
    set<int> s;
    for(int j = 1; j * j <= lcm; j++)
    {
        if(lcm % j == 0)
        {
            s.insert(j);
            s.insert(lcm / j);
        }
    }

    for(auto &i: s)
    {
        for(auto j:m[i]) ans.pb(j);
    }
    sort(ans.begin(), ans.end());

    lcm = 1;
    for(int i:ans)
    {
        int val = v2[i].F;
        int gcd = __gcd(val, lcm);
        lcm *= val;
        lcm /= gcd;
    }

    cout<<lcm<<" "<<mx<<endl;
    for(int i:ans) cout<<i + 1<<' ';
    cout<<endl;
}

int32_t main()
{
    fast();
    cin>>n>>m;
    for(int i = 0; i < n; i++)
    {
        ll a; cin>>a;
        v.pb(make_pair(a, i));
    }
    solve();
}


/* Manish Pant - insider_pants, hello_my_friend */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; }

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int n, m;
vector<pll> v, v2;

void solve()
{
    v2 = v;
    sort(v.begin(), v.end());
    while(!v.empty() && v.back().F > m) v.pop_back();

    if(v.empty())
    {
        cout<<1<<' '<<0<<endl;
        return;
    }

    map<ll, vector<ll>> m;
    for(auto i:v) m[i.F].pb(i.S);

    set<ll> visited;
    ll mx = 0;
    ll idx = -1;
    for(int i = v.size() - 1; i >= 0; i--)
    {
        set<ll> s;
        ll num = v[i].F * (::m / v[i].F);
        if(visited.count(num)) continue;
        for(ll j = 1; j * j <= num; j++)
        {
            if(num % j == 0)
            {
                s.insert(j);
                s.insert(num / j);
            }
        }

        ll t = 0;
        for(auto &j: s) t += ll(m[j].size());

        if(t > mx)
        {
            mx = t;
            idx = i;
        }
    }

    vector<int> ans;
    ll lcm = v[idx].F * (::m / v[idx].F);
    set<int> s;
    for(int j = 1; j * j <= lcm; j++)
    {
        if(lcm % j == 0)
        {
            s.insert(j);
            s.insert(lcm / j);
        }
    }

    for(auto &i: s)
    {
        for(auto j:m[i]) ans.pb(j);
    }
    sort(ans.begin(), ans.end());

    lcm = 1;
    for(int i:ans)
    {
        ll val = v2[i].F;
        ll gcd = __gcd(val, lcm);
        lcm *= val;
        lcm /= gcd;
    }

    cout<<lcm<<" "<<mx<<endl;
    for(int i:ans) cout<<i + 1<<' ';
    cout<<endl;
}

int32_t main()
{
    fast();
    cin>>n>>m;
    for(int i = 0; i < n; i++)
    {
        ll a; cin>>a;
        v.pb(make_pair(a, i));
    }
    solve();
}


/* Manish Pant - insider_pants, hello_my_friend */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; }

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int n, m;
vector<pll> v, v2;

void solve()
{
    v2 = v;
    sort(v.begin(), v.end());
    while(!v.empty() && v.back().F > m) v.pop_back();

    if(v.empty())
    {
        cout<<1<<' '<<0<<endl;
        return;
    }

    map<ll, vector<ll>> m;
    for(auto i:v) m[i.F].pb(i.S);

    set<ll> visited;
    ll mx = 0;
    ll idx = -1;
    for(int i = 0; i < v.size(); i++)
    {
        set<ll> s;
        ll num = v[i].F * (::m / v[i].F);
        if(visited.count(num)) continue;
        for(ll j = 1; j * j <= num; j++)
        {
            if(num % j == 0)
            {
                s.insert(j);
                s.insert(num / j);
            }
        }

        ll t = 0;
        for(auto &j: s) t += ll(m[j].size());

        if(t > mx)
        {
            mx = t;
            idx = i;
        }
    }

    vector<int> ans;
    ll lcm = v[idx].F * (::m / v[idx].F);
    set<int> s;
    for(int j = 1; j * j <= lcm; j++)
    {
        if(lcm % j == 0)
        {
            s.insert(j);
            s.insert(lcm / j);
        }
    }

    for(auto &i: s)
    {
        for(auto j:m[i]) ans.pb(j);
    }
    sort(ans.begin(), ans.end());

    lcm = 1;
    for(int i:ans)
    {
        ll val = v2[i].F;
        ll gcd = __gcd(val, lcm);
        lcm *= val;
        lcm /= gcd;
    }

    cout<<lcm<<" "<<mx<<endl;
    for(int i:ans) cout<<i + 1<<' ';
    cout<<endl;
}

int32_t main()
{
    fast();
    cin>>n>>m;
    for(int i = 0; i < n; i++)
    {
        ll a; cin>>a;
        v.pb(make_pair(a, i));
    }
    solve();
}


/* Manish Pant - insider_pants, hello_my_friend */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; }

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int n, m;
vector<pii> v;

void solve()
{
    sort(v.begin(), v.end());
    while(n > 0 && v[n - 1].F > m) n--;

    if(v.empty())
    {
        cout<<0<<' '<<0<<endl;
        return;
    }

    map<int, vector<int>> m;
    for(int i = 0; i < n; i++) m[v[i].F].pb(i);

    int mx = 0;
    int idx = -1;
    for(int i = 0; i < n; i++)
    {
        set<int> s;
        int num = v[i].F * (::m / v[i].F);
        for(int j = 1; j * j <= num; j++)
        {
            if(num % j == 0)
            {
                s.insert(j);
                s.insert(num / j);
            }
        }

        int t = 0;
        for(auto &j: s) t += int(m[j].size());

        if(t > mx)
        {
            mx = t;
            idx = i;
        }
    }

    vector<int> ans;
    int lcm = v[idx].F * (::m / v[idx].F);
    set<int> s;
    for(int j = 1; j * j <= lcm; j++)
    {
        if(lcm % j == 0)
        {
            s.insert(j);
            s.insert(lcm / j);
        }
    }

    for(auto &i: s)
    {
        for(auto j:m[i]) ans.pb(j);
    }
    sort(ans.begin(), ans.end());
    lcm = 1;
    for(int i:ans)
    {
        int val = v[i].F;
        // cout<<val<<' ';
        int gcd = __gcd(val, lcm);
        lcm *= val;
        lcm /= gcd;
    }

    // cout<<endl;
    cout<<lcm<<" "<<mx<<endl;
    for(int i:ans) cout<<i + 1<<' ';
    cout<<endl;
}

int main()
{
    fast();
    cin>>n>>m;
    for(int i = 0; i < n; i++)
    {
        ll a; cin>>a;
        v.pb(make_pair(a, i));
    }
    solve();
}


/* Manish Pant - insider_pants, hello_my_friend */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; }

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int n, m;
vector<pii> v, v2;

void solve()
{
    v2 = v;
    sort(v.begin(), v.end());
    while(!v.empty() && v.back().F > m) v.pop_back();

    if(v.empty())
    {
        cout<<0<<' '<<0<<endl;
        return;
    }

    map<int, vector<int>> m;
    for(auto i:v) m[i.F].pb(i.S);

    int mx = 0;
    int idx = -1;
    for(int i = 0; i < v.size(); i++)
    {
        set<int> s;
        int num = v[i].F * (::m / v[i].F);
        for(int j = 1; j * j <= num; j++)
        {
            if(num % j == 0)
            {
                s.insert(j);
                s.insert(num / j);
            }
        }

        int t = 0;
        for(auto &j: s) t += int(m[j].size());

        if(t > mx)
        {
            mx = t;
            idx = i;
        }
    }

    vector<int> ans;
    int lcm = v[idx].F * (::m / v[idx].F);
    set<int> s;
    for(int j = 1; j * j <= lcm; j++)
    {
        if(lcm % j == 0)
        {
            s.insert(j);
            s.insert(lcm / j);
        }
    }

    lcm = 1;
    for(auto &i: s)
    {
        for(auto j:m[i]) ans.pb(j);
    }
    sort(ans.begin(), ans.end());\

    for(int i:ans)
    {
        int val = v2[i].F;
        int gcd = __gcd(val, lcm);
        lcm *= val;
        lcm /= gcd;
    }

    cout<<lcm<<" "<<mx<<endl;
    for(int i:ans) cout<<i + 1<<' ';
    cout<<endl;
}

int main()
{
    fast();
    cin>>n>>m;
    for(int i = 0; i < n; i++)
    {
        ll a; cin>>a;
        v.pb(make_pair(a, i));
    }
    solve();
}


#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ ";
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ ";
  for(auto s:S) os<<s<<" ";  return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;}
const int N = 1e6 + 100;

//int spf[N];

//void sieve(){
  //for(int i = 1;i < N ; ++i) spf[i] = i;

  //for(int i = 2;i*1ll*i < N ; ++i){
    //if(spf[i] == i){
      //for(int j = i*i;j < N ; j += i){
        //if(spf[j] = j) spf[j] = i;
      //}
    //}
  //}
/*}*/

vi G[N];
int A[N];
vi freq[N];

int main(){
  fio; cout<<fixed<<setprecision(25);
  //sieve();
  int n, m; cin >> n >> m;
  int x;
  for(int i = 1;i <= n ; ++i){
    cin >> x;
    if(x > m ) continue;
    A[i] = x;
    freq[A[i]].pb(i);
    if(freq[x].size() != 1) continue;
    int curr = x;
    while(curr <= m){
      G[curr].pb(i);
      curr += x;
    }
  }
  int ans = 0 , id = 1;
  for(int i = 1;i <= m ; ++i){
    int curr = 0;
    for(auto it : G[i]) curr += freq[A[it]].size();
    if(curr > ans){
      ans = curr;
      id =i;
    }
  }
  cout << id << ' ' << ans << endl;
  vi vv;
  for(auto it : G[id]){
    for(auto zz : freq[A[it]])
      vv.pb(zz);
    //cout << it << ' ';
  }
  sort(all(vv));
  for(auto it : vv)
    cout << it << ' ';
  cout << endl;

}


#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ ";
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ ";
  for(auto s:S) os<<s<<" ";  return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;}
const int N = 1e6 + 100;

//int spf[N];

//void sieve(){
  //for(int i = 1;i < N ; ++i) spf[i] = i;

  //for(int i = 2;i*1ll*i < N ; ++i){
    //if(spf[i] == i){
      //for(int j = i*i;j < N ; j += i){
        //if(spf[j] = j) spf[j] = i;
      //}
    //}
  //}
/*}*/

vi G[N];

int main(){
  fio; cout<<fixed<<setprecision(25);
  //sieve();
  int n, m; cin >> n >> m;
  int x;
  for(int i = 1;i <= n ; ++i){
    cin >> x;
    int curr = x;
    while(curr <= m){
      G[curr].pb(i);
      curr += x;
    }
  }
  int ans = 0 , id = 0;
  for(int i = 1;i <= m ; ++i){
    if(G[i].size() > ans){
      ans = G[i].size();
      id =i;
    }
  }
  cout << id << ' ' << G[id].size() << endl;
  for(auto it : G[id])
    cout << it << ' ';
  cout << endl;

}


#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ ";
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ ";
  for(auto s:S) os<<s<<" ";  return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;}
const int N = 1e6 + 100;

//int spf[N];

//void sieve(){
  //for(int i = 1;i < N ; ++i) spf[i] = i;

  //for(int i = 2;i*1ll*i < N ; ++i){
    //if(spf[i] == i){
      //for(int j = i*i;j < N ; j += i){
        //if(spf[j] = j) spf[j] = i;
      //}
    //}
  //}
/*}*/

vi G[N];
int A[N];
vi freq[N];

int main(){
  fio; cout<<fixed<<setprecision(25);
  //sieve();
  int n, m; cin >> n >> m;
  int x;
  for(int i = 1;i <= n ; ++i){
    cin >> x;
    A[i] = x;
    freq[A[i]].pb(i);
    if(freq[x].size() != 1) continue;
    int curr = x;
    while(curr <= m){
      G[curr].pb(i);
      curr += x;
    }
  }
  int ans = 0 , id = 1;
  for(int i = 1;i <= m ; ++i){
    int curr = 0;
    for(auto it : G[i]) curr += freq[A[it]].size();
    if(curr > ans){
      ans = curr;
      id =i;
    }
  }
  cout << id << ' ' << ans << endl;
  vi vv;
  for(auto it : G[id]){
    for(auto zz : freq[A[it]])
      vv.pb(zz);
    //cout << it << ' ';
  }
  sort(all(vv));
  for(auto it : vv)
    cout << it << ' ';
  cout << endl;

}


#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ ";
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ ";
  for(auto s:S) os<<s<<" ";  return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;}
const int N = 1e6 + 100;

//int spf[N];

//void sieve(){
  //for(int i = 1;i < N ; ++i) spf[i] = i;

  //for(int i = 2;i*1ll*i < N ; ++i){
    //if(spf[i] == i){
      //for(int j = i*i;j < N ; j += i){
        //if(spf[j] = j) spf[j] = i;
      //}
    //}
  //}
/*}*/

vi G[N];
int A[N];
map<int,vi> freq;

int main(){
  fio; cout<<fixed<<setprecision(25);
  //sieve();
  int n, m; cin >> n >> m;
  int x;
  for(int i = 1;i <= n ; ++i){
    cin >> x;
    A[i] = x;
    freq[A[i]].pb(i);
    if(freq[x].size() != 1) continue;
    int curr = x;
    while(curr <= m){
      G[curr].pb(i);
      curr += x;
    }
  }
  int ans = 0 , id = 1;
  for(int i = 1;i <= m ; ++i){
    int curr = 0;
    for(auto it : G[i]) curr += freq[A[it]].size();
    if(curr > ans){
      ans = curr;
      id =i;
    }
  }
  cout << id << ' ' << ans << endl;
  vi vv;
  for(auto it : G[id]){
    for(auto zz : freq[A[it]])
      vv.pb(zz);
    //cout << it << ' ';
  }
  sort(all(vv));
  for(auto it : vv)
    cout << it << ' ';
  cout << endl;

}


#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ ";
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ ";
  for(auto s:S) os<<s<<" ";  return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;}
const int N = 1e6 + 100;

//int spf[N];

//void sieve(){
  //for(int i = 1;i < N ; ++i) spf[i] = i;

  //for(int i = 2;i*1ll*i < N ; ++i){
    //if(spf[i] == i){
      //for(int j = i*i;j < N ; j += i){
        //if(spf[j] = j) spf[j] = i;
      //}
    //}
  //}
/*}*/

vi G[N];

int main(){
  fio; cout<<fixed<<setprecision(25);
  //sieve();
  int n, m; cin >> n >> m;
  int x;
  for(int i = 1;i <= n ; ++i){
    cin >> x;
    int curr = x;
    while(curr <= m){
      G[curr].pb(i);
      curr += x;
    }
  }
  int ans = 0 , id = 1;
  for(int i = 1;i <= m ; ++i){
    if(G[i].size() > ans){
      ans = G[i].size();
      id =i;
    }
  }
  cout << id << ' ' << G[id].size() << endl;
  for(auto it : G[id])
    cout << it << ' ';
  cout << endl;

}


#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ ";
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ ";
  for(auto s:S) os<<s<<" ";  return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;}
const int N = 1e6 + 100;

//int spf[N];

//void sieve(){
  //for(int i = 1;i < N ; ++i) spf[i] = i;

  //for(int i = 2;i*1ll*i < N ; ++i){
    //if(spf[i] == i){
      //for(int j = i*i;j < N ; j += i){
        //if(spf[j] = j) spf[j] = i;
      //}
    //}
  //}
/*}*/

vi G[N];
int A[N];
map<int,vi> freq;

int main(){
  fio; cout<<fixed<<setprecision(25);
  //sieve();
  int n, m; cin >> n >> m;
  int x;
  for(int i = 1;i <= n ; ++i){
    cin >> x;
    A[i] = x;
    freq[A[i]].pb(i);
    if(freq[x].size() != 1) continue;
    int curr = x;
    while(curr <= m){
      G[curr].pb(i);
      curr += x;
    }
  }
  int ans = 0 , id = 1;
  for(int i = 1;i <= m ; ++i){
    int curr = 0;
    for(auto it : G[i]) curr += freq[A[id]].size();
    if(curr > ans){
      ans = curr;
      id =i;
    }
  }
  cout << id << ' ' << ans << endl;
  vi vv;
  for(auto it : G[id]){
    for(auto zz : freq[A[it]])
      vv.pb(zz);
    //cout << it << ' ';
  }
  sort(all(vv));
  for(auto it : vv)
    cout << it << ' ';
  cout << endl;

}


#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin>>n>>m;
    int a[n];
    for(int i = 0;i<n;i++) cin>>a[i];
    int freq[m+1];
    for(int i = 0;i<=m;i++) freq[i] = 0;
    for(int i = 0;i<n;i++){
        if(a[i]<=m) freq[a[i]]++;
    }
    int cnt[m+1];
    int l = 1;
    int maxi = 0;
    for(int i = 0;i<=m;i++) cnt[i] = 0;
    for(int i = 1;i<=m;i++){
        if(freq[i]==0) continue;
        for(int j = i;j<=m;j+=i){
            cnt[j]+=freq[i];
            if((cnt[j]>maxi) || (cnt[j]==maxi && j<l)){
                l = j;
                maxi = cnt[j];
            }
        }
    }
    cout<<l<<' '<<maxi<<'\n';
    for(int i = 0;i<n;i++){
        if(l%a[i]==0) cout<<(i+1)<<' ';
    }
    cout<<"\n";
    return 0;
}
//b k
//1 3
//


#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#define int long long
using namespace std;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin>>n>>m;
    int a[n];
    for(int i = 0;i<n;i++) cin>>a[i];
    int freq[m+1];
    for(int i = 0;i<=m;i++) freq[i] = 0;
    for(int i = 0;i<n;i++){
        if(a[i]<=m) freq[a[i]]++;
    }
    int cnt[m+1];
    for(int i = 0;i<=m;i++) cnt[i] = 0;
    for(int i = 1;i<=m;i++){
        for(int j = 1;j*j<=i;j++){
            if(i%j!=0) continue;
            cnt[i]+=freq[j];
            int opp = i/j;
            if(opp!=j) cnt[i]+=freq[opp];
        }
        //cout<<i<<" "<<cnt[i]<<endl;
    }
    int l = 1;
    int maxi = 0;
    for(int i = 1;i<=m;i++){
        if(cnt[i]>maxi){
            l = i;
            maxi = cnt[i];
        }
    }
    cout<<l<<" "<<maxi<<endl;
    for(int i = 0;i<n;i++){
        if(l%a[i]==0) cout<<(i+1)<<" ";
    }
    cout<<endl;
}
//b k
//1 3
//


#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin>>n>>m;
    int a[n];
    for(int i = 0;i<n;i++) cin>>a[i];
    int freq[m+1];
    for(int i = 0;i<=m;i++) freq[i] = 0;
    for(int i = 0;i<n;i++){
        if(a[i]<=m) freq[a[i]]++;
    }
    int cnt[m+1];
    int l = 1;
    int maxi = 0;
    for(int i = 0;i<=m;i++) cnt[i] = 0;
    for(int i = 1;i<=m;i++){
        for(int j = 1;(j*j)<=i;j++){
            if((i%j)!=0) continue;
            cnt[i]+=freq[j];
            int opp = i/j;
            if(opp!=j) cnt[i]+=freq[opp];
        }
        //cout<<i<<" "<<cnt[i]<<endl;
        if((cnt[i]>maxi) || (cnt[i]==maxi && i<l)){
            l = i;
            maxi = cnt[i];
        }
    }
    cout<<l<<" "<<maxi<<"\n";
    for(int i = 0;i<n;i++){
        if(l%a[i]==0) cout<<(i+1)<<" ";
    }
    cout<<"\n";
}
//b k
//1 3
//


#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin>>n>>m;
    int a[n];
    for(int i = 0;i<n;i++) cin>>a[i];
    int freq[m+1];
    for(int i = 0;i<=m;i++) freq[i] = 0;
    for(int i = 0;i<n;i++){
        if(a[i]<=m) freq[a[i]]++;
    }
    int cnt[m+1];
    int l = 1;
    int maxi = 0;
    for(int i = 0;i<=m;i++) cnt[i] = 0;
    for(int i = 1;i<=m;i++){
        for(int j = 1;(j*j)<=i;j++){
            if((i%j)!=0) continue;
            cnt[i]+=freq[j];
            int opp = i/j;
            if(opp!=j) cnt[i]+=freq[opp];
        }
        //cout<<i<<" "<<cnt[i]<<endl;
        if((cnt[i]>maxi) || (cnt[i]==maxi && i<l)){
            l = i;
            maxi = cnt[i];
        }
    }
    cout<<l<<' '<<maxi<<'\n';
    for(int i = 0;i<n;i++){
        if(l%a[i]==0) cout<<(i+1)<<' ';
    }
    cout<<"\n";
    return 0;
}
//b k
//1 3
//


#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#define int long long
using namespace std;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin>>n>>m;
    int a[n];
    for(int i = 0;i<n;i++) cin>>a[i];
    map<int, int> freq;
    int cnt[m+1];
    for(int i = 0;i<=m;i++) cnt[i] = 0;
    for(int i = 0;i<n;i++) freq[a[i]]++;
    for(int i = 1;i<=m;i++){
        for(int j = 1;j*j<=i;j++){
            if(i%j!=0) continue;
            cnt[i]+=freq[j];
            int opp = i/j;
            if(opp!=j) cnt[i]+=freq[opp];
        }
        //cout<<i<<" "<<cnt[i]<<endl;
    }
    int l = 1;
    int maxi = 0;
    for(int i = 1;i<=m;i++){
        if(cnt[i]>maxi){
            l = i;
            maxi = cnt[i];
        }
    }
    cout<<l<<" "<<maxi<<endl;
    for(int i = 0;i<n;i++){
        if(l%a[i]==0) cout<<(i+1)<<" ";
    }
    cout<<endl;
}
//b k
//1 3
//


#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin>>n>>m;
    int a[n];
    for(int i = 0;i<n;i++) cin>>a[i];
    int freq[m+1];
    for(int i = 0;i<=m;i++) freq[i] = 0;
    for(int i = 0;i<n;i++){
        if(a[i]<=m) freq[a[i]]++;
    }
    int cnt[m+1];
    int l = 1;
    int maxi = 0;
    for(int i = 0;i<=m;i++) cnt[i] = 0;
    for(int i = 1;i<=m;i++){
        if(freq[i]==0) continue;
        for(int j = i;j<=m;j+=i){
            cnt[j]+=freq[i];
            if((cnt[i]>maxi) || (cnt[i]==maxi && i<l)){
                l = i;
                maxi = cnt[i];
            }
        }
    }
    cout<<l<<' '<<maxi<<'\n';
    for(int i = 0;i<n;i++){
        if(l%a[i]==0) cout<<(i+1)<<' ';
    }
    cout<<"\n";
    return 0;
}
//b k
//1 3
//


#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const long double EPS = 1e-14;
const int maxn = 1000500;
const int mod = 1e9 + 7;
vector < int >  cnt[maxn];

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;
        if(x > m) continue;
        cnt[x].push_back(i + 1);
    }
    int ans = 0, idx = -1;
    for(int i = 0 ; i <= m ; ++i)
        if(sz(cnt[i])){
            int sm = 0;
            for(int j = 1 ; j * j <= i ; ++j)
                if(i % j == 0){
                    sm += sz(cnt[j]);
                    if(j != i / j) sm += sz(cnt[i / j]);
                }
            if(sm > ans) ans = sm, idx = i;
        }
    if(idx == -1){
        cout << "0 0 \n";
        return 0;
    }
    cout << idx << ' ' << ans << '\n';
    vector < int > rs;
    for(int i = 1 ; i <= idx ; ++i)
        if(idx % i == 0){
            for(auto x : cnt[i]) rs.push_back(x);
        }
    sort(all(rs));
    for(auto x : rs) cout << x << ' ';
    cout << '\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b));}
const long double EPS = 1e-14;
const int maxn = 1000500;
const int mod = 1e9 + 7;
vector < int >  cnt[maxn];
int res[maxn];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    int ad = 0;
    for(int i = 0 ; i < n ; ++i){
        int x;
        cin >> x;
        if(x > m) continue;
        cnt[x].push_back(i + 1);
        ad++;
    }
    int ans = 0, idx = -1;
    for(int i = 1 ; i <= m ; ++i){
            int sm = sz(cnt[i]);
            for(int j = 2 ; j * j <= i ; ++j)
                if(i % j == 0){
                    if(j == i / j) sm += res[j];
                    else sm += res[j] + res[i / j] - res[gcd(j, i / j)];
                    break;
                }
            if(sm > ans) ans = sm, idx = i;
            res[i] = sm;
        }
    if(idx == -1){
        cout << "1 0 \n";
        return 0;
    }
    cout << idx << ' ' << ans << '\n';
    vector < int > rs;
    for(int i = 1 ; i <= idx ; ++i)
        if(idx % i == 0){
            for(auto x : cnt[i]) rs.push_back(x);
        }
    sort(all(rs));
    for(auto x : rs) cout << x << ' ';
    cout << '\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const long double EPS = 1e-14;
const int maxn = 1000500;
const int mod = 1e9 + 7;
vector < int >  cnt[maxn];

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;
        if(x > m) continue;
        cnt[x].push_back(i + 1);
    }
    int ans = 0, idx = -1;
    for(int i = 1 ; i <= m ; ++i){
            int sm = 0;
            for(int j = 1 ; j * j <= i ; ++j)
                if(i % j == 0){
                    sm += sz(cnt[j]);
                    if(j != i / j) sm += sz(cnt[i / j]);
                }
            if(sm > ans) ans = sm, idx = i;
        }
    if(idx == -1){
        cout << "0 0 \n";
        return 0;
    }
    cout << idx << ' ' << ans << '\n';
    vector < int > rs;
    for(int i = 1 ; i <= idx ; ++i)
        if(idx % i == 0){
            for(auto x : cnt[i]) rs.push_back(x);
        }
    sort(all(rs));
    for(auto x : rs) cout << x << ' ';
    cout << '\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const long double EPS = 1e-14;
const int maxn = 1000500;
const int mod = 1e9 + 7;
vector < int >  cnt[maxn];
int res[maxn];

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;
        if(x > m) continue;
        cnt[x].push_back(i + 1);
    }
    int ans = 0, idx = -1;
    for(int i = 1 ; i <= m ; ++i)
        if(sz(cnt[i]))
            for(int j = i ; j <= m ; j += i)
                res[j] += sz(cnt[i]);
    for(int i = 0 ; i <= m ; ++i)
        if(res[i] > ans){
            ans = res[i];
            idx = i;
        }
    if(idx == -1){
        cout << "1 0 \n";
        return 0;
    }
    cout << idx << ' ' << ans << '\n';
    vector < int > rs;
    for(int i = 1 ; i <= idx ; ++i)
        if(idx % i == 0){
            for(auto x : cnt[i]) rs.push_back(x);
        }
    sort(all(rs));
    for(auto x : rs) cout << x << ' ';
    cout << '\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const long double EPS = 1e-14;
const int maxn = 1000500;
const int mod = 1e9 + 7;
vector < int >  cnt[maxn];

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;
        if(x > m) continue;
        cnt[x].push_back(i + 1);
    }
    int ans = 0, idx = -1;
    for(int i = 1 ; i <= m ; ++i){
            int sm = 0;
            for(int j = 1 ; j * j <= i ; ++j)
                if(i % j == 0){
                    sm += sz(cnt[j]);
                    if(j != i / j) sm += sz(cnt[i / j]);
                }
            if(sm > ans) ans = sm, idx = i;
        }
    if(idx == -1){
        cout << "1 0 \n";
        return 0;
    }
    cout << idx << ' ' << ans << '\n';
    vector < int > rs;
    for(int i = 1 ; i <= idx ; ++i)
        if(idx % i == 0){
            for(auto x : cnt[i]) rs.push_back(x);
        }
    sort(all(rs));
    for(auto x : rs) cout << x << ' ';
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[1000];

 	int t=1,a;
	cin >> n >> m;

	vector<int>aux(m);
	vector<int>v;

	for(int i=0;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> a;

			v.push_back(a);
			aux[a]++;

	}

	for(int i = 1;i<m;i++){
		if(aux[i]!=0){
			for(int j=i;j<=m;j+=i){
				c[j]+=aux[i];
			}
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[10000000];

 	int t=1,a;
	cin >> n >> m;

	vector<int>aux(m);
	vector<int>v;

	for(int i=0;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> a;

			v.push_back(a);
			if(a<=m)
				aux[a]++;

	}

	for(int i = 1;i<m;i++){
		if(aux[i]!=0){
			for(int j=i;j<=m;j+=i){
				c[j]+=aux[i];
			}
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m,c;
    int c[10000000];

 	int t=1,a;
	cin >> n >> m;

	vector<int>aux(m+10);
	vector<int>v;

	for(int i=0;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> a;

			v.push_back(a);
			if(a<=m)
				aux[a]++;

	}

	for(int i = 1;i<=m;i++){
		if(aux[i]!=0){
			for(int j=i;j<=m;j+=i){
				c[j]+=aux[i];
			}
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[10000000];

 	int t=1,a;
	cin >> n >> m;

	vector<int>aux(m+10);
	vector<int>v;

	for(int i=0;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> a;

			v.push_back(a);
			if(a<=m)
				aux[a]++;

	}

	for(int i = 1;i<m;i++){
		if(aux[i]!=0){
			for(int j=i;j<=m;j+=i){
				c[j]+=aux[i];
			}
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[1000];

 	int t=1,a;
	cin >> n >> m;

	vector<int>aux(m);
	vector<int>v;

	for(int i=0;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> a;

		if(a<=m){
			v.push_back(a);
			aux[a]++;
		}
	}

	for(int i = 1;i<m;i++){
		if(aux[i]!=0){
			for(int j=i;j<=m;j+=i){
				c[j]+=aux[i];
			}
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[10000000];
	string resp;
 	int t=1;
	cin >> n >> m;
	vector<int>v(n);

	for(int i=1;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> v[i];
		for(int j = v[i] ; j<=m;j+=v[i]){
			c[j]++;
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int m,n;
    int c[10000000];

 	int t=1,a;
	cin >> n >> m;

	vector<int>aux(m+10);
	vector<int>v;

	for(int i=0;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> a;

			v.push_back(a);
			if(a<=m)
				aux[a]++;

	}

	for(int i = 1;i<=m;i++){
		if(aux[i]!=0){
			for(int j=i;j<=m;j+=i){
				c[j]+=aux[i];
			}
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[10000000];

 	int t=1,a;
	cin >> n >> m;

	vector<int>aux(m+10);
	vector<int>v;

	for(int i=0;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> a;

			v.push_back(a);
			if(a<=m)
				aux[a]++;

	}

	for(int i = 1;i<=m;i++){
		if(aux[i]!=0){
			for(int j=i;j<=m;j+=i){
				c[j]+=aux[i];
			}
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[10000000];

 	int t=1,a,b;
	cin >> n >> m;

	vector<int>v(n);
	map<int,int>ma;

	for(int i=1;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> v[i];
		ma[v[i]]++;
	}

	for(auto i = ma.begin();i!=ma.end();i++){
		a = i->first;
		b = i->second;
		for(int j=a;j<=m;j+=a){
			c[j]+=b;
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[1000];
	string resp;
 	int t=1;
	cin >> n >> m;
	vector<int>v(n);

	for(int i=1;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> v[i];
		for(int j = v[i] ; j<=m;j+=v[i]){
			c[j]++;
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[10000000];

 	int t=1,a;
	cin >> n >> m;

	vector<int>aux(m);
	vector<int>v;

	for(int i=0;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> a;

			v.push_back(a);
			aux[a]++;

	}

	for(int i = 1;i<m;i++){
		if(aux[i]!=0){
			for(int j=i;j<=m;j+=i){
				c[j]+=aux[i];
			}
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    int c[10000000];

 	int t=1;
	cin >> n >> m;

	vector<int>v(n);
	map<int,int>ma;

	for(int i=1;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> v[i];
		ma[v[i]]++;
	}

	for(auto i = ma.begin();i!=ma.end();i++){
		for(int j=i->first;j<=m;j+=i->first){
			c[j]+=i->second;
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int m,n;
    int c[10000000];

 	int t=1,a;
	cin >> n >> m;

	vector<int>aux(m+10);
	vector<int>v;

	for(int i=0;i<=m;i++){
		c[i]=0;
	}

	for(int i=0;i<n;i++){
		cin >> a;

			v.push_back(a);
			if(a<=m)
				aux[a]++;

	}

	for(int i = 1;i<m;i++){
		if(aux[i]!=0){
			for(int j=i;j<=m;j+=i){
				c[j]+=aux[i];
			}
		}
	}

	for(int i=1;i<=m;i++){
		if(c[i]>c[t]){
			t=i;
		}
	}

	cout << t << " " << c[t] << endl;

	for(int i=0;i<n;i++){
		if(t%v[i]==0) cout << i+1 << " ";
	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
#define space " "
#define debug(val) "[ " << #val " : " << (val) << " ]" << space
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vii vector<vector<int>>
#define PI (double)(atan(1)*4)
#define pb push_back
#define ff first
#define ss second
#define pi pair<int , int >
#define INF LONG_LONG_MAX
#define EPS (double)0.0000000001
vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

//#define _DEBUG
const int maxN = 2e5 + 4;
ll inf = 1e14;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), f(1e6 + 3 , 0 );
    set<int> st ;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        st.insert(a[i]) ;
        if (a[i] <= 1e6) {
            f[a[i]]++;
        }
    }
    int N = 1000000;
    for (int i = 1; i <= m; i++) {
        if(!st.count(i)) continue;
        for (int j = i + i; j <= m; j += i) {
            f[j] += f[i];
        }
    }
    int ans = 0;
    int num = 0;
    for (int i = 1; i <= m; i++) {
        if (f[i] > ans) {
            num = i;
            ans = f[i];
        }
    }
    vector<int> res;
    for (int i = 0; i < n; i++) {
        if (num % a[i] == 0) {
            res.push_back(i + 1);
        }
    }
    cout << num << space << (int) res.size()<< endl;
    for (auto v : res) cout << v << space;
    cout <<endl;
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0); // FAST IO
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        // cout << "Case #" << i << ": ";
        solve();
    }

}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
#define space " "
#define debug(val) "[ " << #val " : " << (val) << " ]" << space
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vii vector<vector<int>>
#define PI (double)(atan(1)*4)
#define pb push_back
#define ff first
#define ss second
#define pi pair<int , int >
#define INF LONG_LONG_MAX
#define EPS (double)0.0000000001
vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

//#define _DEBUG

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), f(1e6 + 3, 0), f2(1e6 + 3, 0);
    set<int> st;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        st.insert(a[i]);
        if (a[i] <= 1e6) {
            f[a[i]]++;
            f2[a[i]]++;
        }
    }
    for (int i = 1; i <= m; i++) {
        if (!f2[i]) continue;
        for (int j = i + i; j <= m; j += i) {
            f[j] += f2[i];
        }
    }
    int ans = 0;
    int num = 0;
    for (int i = 1; i <= m; i++) {
        if (f[i] > ans) {
            num = i;
            ans = f[i];
        }
    }
    vector<int> res;
    for (int i = 0; i < n; i++) {
        if (num % a[i] == 0) {
            res.push_back(i + 1);
        }
    }
    cout << num << space << (int) res.size() << endl;
    for (auto v : res) cout << v << space;
    cout << endl;
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0); // FAST IO
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        // cout << "Case #" << i << ": ";
        solve();
    }

}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
#define space " "
#define debug(val) "[ " << #val " : " << (val) << " ]" << space
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vii vector<vector<int>>
#define PI (double)(atan(1)*4)
#define pb push_back
#define ff first
#define ss second
#define pi pair<int , int >
#define INF LONG_LONG_MAX
#define EPS (double)0.0000000001
vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

//#define _DEBUG

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), f(1e6 + 3, 0), f2(1e6 + 3, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] <= m) {
            f[a[i]]++;
            f2[a[i]]++;
        }
    }
    for (int i = 1; i <= m; i++) {
        if (!f2[i]) continue;
        for (int j = i + i; j <= m; j += i) {
            f[j] += f2[i];
        }
    }
    int ans = 0;
    int num = 1;
    for (int i = 1; i <= m; i++) {
        if (f[i] > ans) {
            num = i;
            ans = f[i];
        }
    }
    vector<int> res;
    for (int i = 0; i < n; i++) {
        if ((ans != 1) && (num % a[i] == 0)) {
            res.push_back(i + 1);
        }
    }
    cout << num << space << (int) res.size() << endl;
    for (auto v : res) cout << v << space;
    cout << endl;
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0); // FAST IO
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        // cout << "Case #" << i << ": ";
        solve();
    }

}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
#define space " "
#define debug(val) "[ " << #val " : " << (val) << " ]" << space
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vii vector<vector<int>>
#define PI (double)(atan(1)*4)
#define pb push_back
#define ff first
#define ss second
#define pi pair<int , int >
#define INF LONG_LONG_MAX
#define EPS (double)0.0000000001
vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

//#define _DEBUG

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), f(1e6 + 3, 0), f2(1e6 + 3, 0);
    set<int> st;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        st.insert(a[i]);
        if (a[i] <= 1e6) {
            f[a[i]]++;
            f2[a[i]]++;
        }
    }
    for (int i = 1; i <= m; i++) {
        if (!f2[i]) continue;
        for (int j = i + i; j <= m; j += i) {
            f[j] += f2[i];
        }
    }
    int ans = 0;
    int num = 0;
    for (int i = 1; i <= m; i++) {
        if (f[i] > ans) {
            num = i;
            ans = f[i];
        }
    }
    vector<int> res;
    for (int i = 0; i < n; i++) {
        if ((ans != 0) && (num % a[i] == 0)) {
            res.push_back(i + 1);
        }
    }
    cout << num << space << (int) res.size() << endl;
    for (auto v : res) cout << v << space;
    cout << endl;
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0); // FAST IO
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        // cout << "Case #" << i << ": ";
        solve();
    }

}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
#define space " "
#define debug(val) "[ " << #val " : " << (val) << " ]" << space
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vii vector<vector<int>>
#define PI (double)(atan(1)*4)
#define pb push_back
#define ff first
#define ss second
#define pi pair<int , int >
#define INF LONG_LONG_MAX
#define EPS (double)0.0000000001
vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

//#define _DEBUG

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), f(1e6 + 3, 0), f2(1e6 + 3, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] <= m) {
            f[a[i]]++;
            f2[a[i]]++;
        }
    }
    for (int i = 1; i <= m; i++) {
        if (!f2[i]) continue;
        for (int j = i + i; j <= m; j += i) {
            f[j] += f2[i];
        }
    }
    int ans = 0;
    int num = 0;
    for (int i = 1; i <= m; i++) {
        if (f[i] > ans) {
            num = i;
            ans = f[i];
        }
    }
    vector<int> res;
    for (int i = 0; i < n; i++) {
        if ((ans != 0) && (num % a[i] == 0)) {
            res.push_back(i + 1);
        }
    }
    if (num == 0) num = 1;
    cout << num << space << (int) res.size() << endl;
    for (auto v : res) cout << v << space;
    cout << endl;
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0); // FAST IO
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        // cout << "Case #" << i << ": ";
        solve();
    }

}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;

int f[N];
int a[N];
int n,m;
int b[N];
int sum[N];

void pre()
{

	for(int i=1;i<N;i++)
	{
		sum[i]+=a[i];
		for(int j=2*i;j<N;j+=i)
			sum[j]+=a[i];
	}
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>b[i];
    	if(b[i]<=1e6)
    	a[b[i]]++;
    }
    pre();
    int mx=0;
    int index=0;
    for(int i=1;i<=m;i++)
    {
    	if(mx<sum[i])
    	{
    		mx=sum[i];
    		index=i;
    	}
    }
    vector<int> ans;
    for(int i=1;i<=n;i++)
    {
    	if(index%b[i]==0)
    		ans.push_back(i);
    }
    cout<<index<<' '<<ans.size()<<endl;
    for(auto it:ans)
    	cout<<it<<' ';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;

int f[N];
int a[N];
int n,m;
int b[N];
int sum[N];

void pre()
{
	for(int i=2;i*i<N;i++)
	{
		if(!f[i])
		{
			f[i]=1;
			sum[i]+=a[i];
			for(int j=2*i;j<N;j+=i)
			{
				f[j]=1;
				sum[j]+=a[i];
			}
		}
		else
			sum[i]+=a[i];
	}
	for(int i=1;i<N;i++)
	{
		if(!f[i])
			sum[i]+=a[i];
	}
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>b[i];
    	if(b[i]<=1e6)
    	a[b[i]]++;
    }
    pre();
    int mx=0;
    int index=0;
    for(int i=1;i<=m;i++)
    {
    	if(mx<sum[i])
    	{
    		mx=sum[i];
    		index=i;
    	}
    }
    vector<int> ans;
    for(int i=1;i<=n;i++)
    {
    	if(index%b[i]==0)
    		ans.push_back(i);
    }
    cout<<index<<' '<<ans.size()<<endl;
    for(auto it:ans)
    	cout<<it<<' ';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;

int f[N];
int a[N];
int n,m;
int b[N];
int sum[N];

void pre()
{
	for(int i=1;i*i<N;i++)
	{
		if(!f[N])
		{
			f[i]=1;
			sum[i]+=a[i];
			for(int j=2*i;j<N;j+=i)
			{
				f[j]=1;
				sum[j]+=sum[i]+a[j];
			}
		}
		else
		{
			f[i]=1;
			sum[i]+=a[i];
		}
	}
	for(int i=1;i<N;i++)
	{
		if(!f[i])
			sum[i]+=a[i];
	}
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>b[i];
    	a[b[i]]++;
    }
    pre();
    int mx=0;
    int index;
    for(int i=1;i<=m;i++)
    {
    	if(mx<sum[i])
    	{
    		mx=sum[i];
    		index=i;
    	}
    }
    vector<int> ans;
    for(int i=1;i<=n;i++)
    {
    	if(index%b[i]==0)
    		ans.push_back(i);
    }
    cout<<index<<' '<<ans.size()<<endl;
    for(auto it:ans)
    	cout<<it<<' ';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;

int f[N];
int a[N];
int n,m;
int b[N];
int sum[N];

void pre()
{

	for(int i=1;i<N;i++)
	{
		sum[i]+=a[i];
		for(int j=2*i;j<N;j+=i)
			sum[j]+=a[i];
	}
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>b[i];
    	if(b[i]<=1e6)
    	a[b[i]]++;
    }
    pre();
    int mx=0;
    int index=1;
    for(int i=1;i<=m;i++)
    {
    	if(mx<sum[i])
    	{
    		mx=sum[i];
    		index=i;
    	}
    }
    vector<int> ans;
    for(int i=1;i<=n;i++)
    {
    	if(index%b[i]==0)
    		ans.push_back(i);
    }
    cout<<index<<' '<<ans.size()<<endl;
    for(auto it:ans)
    	cout<<it<<' ';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;

int f[N];
int a[N];
int n,m;
int b[N];
int sum[N];

void pre()
{
	for(int i=1;i*i<N;i++)
	{
		if(!f[N])
		{
			f[i]=1;
			sum[i]+=a[i];
			for(int j=2*i;j<N;j+=i)
			{
				f[j]=1;
				sum[j]+=a[i];
			}
		}
	}
	for(int i=1;i<N;i++)
	{
		if(!f[i])
			sum[i]+=a[i];
	}
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>b[i];
    	a[b[i]]++;
    }
    pre();
    int mx=0;
    int index;
    for(int i=1;i<=m;i++)
    {
    	if(mx<sum[i])
    	{
    		mx=sum[i];
    		index=i;
    	}
    }
    vector<int> ans;
    for(int i=1;i<=n;i++)
    {
    	if(index%b[i]==0)
    		ans.push_back(i);
    }
    cout<<index<<' '<<ans.size()<<endl;
    for(auto it:ans)
    	cout<<it<<' ';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;

int f[N];
int a[N];
int n,m;
int b[N];
int sum[N];

void pre()
{
	for(int i=1;i*i<N;i++)
	{
		if(!f[N])
		{
			f[i]=1;
			sum[i]+=a[i];
			for(int j=2*i;j<N;j+=i)
			{
				f[j]=1;
				sum[j]+=a[i];
			}
		}
	}
	for(int i=1;i<N;i++)
	{
		if(!f[i])
			sum[i]+=a[i];
	}
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>b[i];
    	if(b[i]<=1e6)
    	a[b[i]]++;
    }
    pre();
    int mx=0;
    int index;
    for(int i=1;i<=m;i++)
    {
    	if(mx<sum[i])
    	{
    		mx=sum[i];
    		index=i;
    	}
    }
    vector<int> ans;
    for(int i=1;i<=n;i++)
    {
    	if(index%b[i]==0)
    		ans.push_back(i);
    }
    cout<<index<<' '<<ans.size()<<endl;
    for(auto it:ans)
    	cout<<it<<' ';

    return 0;
}


#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::vector;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    vector<int> arr(n);
    vector<int> count(m + 1);
    for (int i = 0; i < n; ++i) {
        int num;
        cin >> num;
        arr[i] = num;
        if (i <= m) {
            for (int j = num; j <= m; j += num) ++count[j];
        }
    }

    int max = 0;
    int lcm = 0;
    for (int i = 1; i <= m; ++i) {
        if (count[i] > max) {
            max = count[i];
            lcm = i;
        }
    }
    vector<int> subseq;
    for (int i = 0; i < n; ++i) {
        if (!(lcm % arr[i])) subseq.push_back(i + 1);
    }

    cout << lcm << ' ' << subseq.size() << '\n';
    bool first_output = true;
    for (const auto& i : subseq) {
        if (first_output)
            first_output = false;
        else
            cout << ' ';
        cout << i;
    }
    cout << '\n';
    return 0;
}


#include <iostream>
#include <map>
#include <vector>

using std::cin;
using std::cout;
using std::map;
using std::vector;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    vector<int>   arr(n);
    map<int, int> num_cnt;
    vector<int>   all_cnt(m + 1);
    for (int i = 0; i < n; ++i) {
        int num;
        cin >> num;
        arr[i] = num;
        ++num_cnt[num];
    }
    for (const auto& i : num_cnt) {
        int num = i.first;
        int cnt = i.second;
        for (int j = num; j <= m; j += num) all_cnt[j] += cnt;
    }

    int max = 0;
    int lcm = 1;
    for (int i = 1; i <= m; ++i) {
        if (all_cnt[i] > max) {
            max = all_cnt[i];
            lcm = i;
        }
    }
    vector<int> subseq;
    for (int i = 0; i < n; ++i) {
        if (!max) break;
        if (!(lcm % arr[i])) subseq.push_back(i + 1);
    }

    cout << lcm << ' ' << subseq.size() << '\n';
    bool first_output = true;
    for (const auto& i : subseq) {
        if (first_output)
            first_output = false;
        else
            cout << ' ';
        cout << i;
    }
    cout << '\n';
    return 0;
}


#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::vector;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    vector<int> arr(n);
    vector<int> count(m + 1);
    for (int i = 0; i < n; ++i) {
        int num;
        cin >> num;
        arr[i] = num;
        for (int j = num; j <= m; j += num) ++count[j];
    }

    int max = 0;
    int lcm = 0;
    for (int i = 1; i <= m; ++i) {
        if (count[i] > max) {
            max = count[i];
            lcm = i;
        }
    }
    vector<int> subseq;
    for (int i = 0; i < n; ++i) {
        if (!(lcm % arr[i])) subseq.push_back(i + 1);
    }

    cout << lcm << ' ' << subseq.size() << '\n';
    bool first_output = true;
    for (const auto& i : subseq) {
        if (first_output)
            first_output = false;
        else
            cout << ' ';
        cout << i;
    }
    cout << '\n';
    return 0;
}


#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::vector;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    vector<int> arr(n);
    vector<int> count(m + 1);
    for (int i = 0; i < n; ++i) {
        int num;
        cin >> num;
        arr[i] = num;
        for (int j = num; j <= m; j += num) ++count[j];
    }

    int max = 0;
    int lcm = 1;
    for (int i = 1; i <= m; ++i) {
        if (count[i] > max) {
            max = count[i];
            lcm = i;
        }
    }
    vector<int> subseq;
    for (int i = 0; i < n; ++i) {
        if (!max) break;
        if (!(lcm % arr[i])) subseq.push_back(i + 1);
    }

    cout << lcm << ' ' << subseq.size() << '\n';
    bool first_output = true;
    for (const auto& i : subseq) {
        if (first_output)
            first_output = false;
        else
            cout << ' ';
        cout << i;
    }
    cout << '\n';
    return 0;
}


#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(m + 1), a(n);
  for (auto& x : a) {
    cin >> x;
    if (x <= m) cnt[x]++;
  }
  vector<int> dp(m + 1);
  for (int i = 1; i <= m; ++i) {
    if (cnt[i] == 0) continue;
    for (int j = i; j <= m; j += i) {
      dp[j] += cnt[i];
    }
  }
  int best = 1, k = -1;
  for (int i = 1; i <= m; ++i) {
    if (best < dp[i]) {
      best = dp[i];
      k = i;
    }
  }
  if (k < 0) {
    cout << 1 << " " << 0 << '\n';
    return 0;
  }

  cout << k << " " << best << '\n';
  vector<int> ret;
  for (int i = 0; i < n; ++i) {
    if (k % a[i] == 0) ret.push_back(i + 1);
  }
  for (int i = 0; i < SZ(ret); ++i) {
    cout << ret[i] << " \n"[i + 1 == SZ(ret)];
  }
  return 0;
}


#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(m + 1), a(n);
  for (auto& x : a) {
    cin >> x;
    if (x <= m) cnt[x]++;
  }
  vector<int> dp(m + 1);
  for (int i = 1; i <= m; ++i) {
    if (cnt[i] == 0) continue;
    for (int j = i; j <= m; j += i) {
      dp[j] += cnt[i];
    }
  }
  int best = 0, k = -1;
  for (int i = 1; i <= m; ++i) {
    if (best < dp[i]) {
      best = dp[i];
      k = i;
    }
  }
  if (k < 0) {
    cout << 1 << " " << 0 << "\n\n";
    return 0;
  }

  cout << k << " " << best << '\n';
  vector<int> ret;
  for (int i = 0; i < n; ++i) {
    if (k % a[i] == 0) ret.push_back(i + 1);
  }
  for (int i = 0; i < SZ(ret); ++i) {
    cout << ret[i] << " \n"[i + 1 == SZ(ret)];
  }
  return 0;
}


#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(m + 1), a(n);
  for (auto& x : a) {
    cin >> x;
    if (x <= m) cnt[x]++;
  }
  vector<int> dp(m + 1);
  for (int i = 1; i <= m; ++i) {
    if (cnt[i] == 0) continue;
    for (int j = i; j <= m; j += i) {
      dp[j] += cnt[i];
    }
  }
  int best = 1, k = -1;
  for (int i = 1; i <= m; ++i) {
    if (best < dp[i]) {
      best = dp[i];
      k = i;
    }
  }

  cout << k << " " << best << '\n';
  vector<int> ret;
  for (int i = 0; i < n; ++i) {
    if (k % a[i] == 0) ret.push_back(i + 1);
  }
  for (int i = 0; i < SZ(ret); ++i) {
    cout << ret[i] << " \n"[i + 1 == SZ(ret)];
  }
  return 0;
}


#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(m + 1), a(n);
  for (auto& x : a) {
    cin >> x;
    if (x <= m) cnt[x]++;
  }
  vector<int> dp(m + 1);
  for (int i = 1; i <= m; ++i) {
    if (cnt[i] == 0) continue;
    for (int j = i; j <= m; j += i) {
      dp[j] += cnt[i];
    }
  }
  int best = 1, k = -1;
  for (int i = 1; i <= m; ++i) {
    if (best < dp[i]) {
      best = dp[i];
      k = i;
    }
  }
  if (k < 0) {
    cout << 1 << " " << 0 << "\n\n";
    return 0;
  }

  cout << k << " " << best << '\n';
  vector<int> ret;
  for (int i = 0; i < n; ++i) {
    if (k % a[i] == 0) ret.push_back(i + 1);
  }
  for (int i = 0; i < SZ(ret); ++i) {
    cout << ret[i] << " \n"[i + 1 == SZ(ret)];
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, a[1000004], d[1000004];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("bdnt.inp", "r", stdin);
    //freopen("bdnt.out", "w", stdout);
    cin >> n >> m;
    int i, j;
    for(i = 1; i <= n; i++) cin >> a[i];
    for(i = 1; i <= m; i++) d[i] = 0;
    for(i = 1; i <= n; i++)
        if(a[i] <= m) d[a[i]]++;
    for(i = m; i > 0; i--)
        if(d[i])
            for(j = i + i; j <= m; j += i) d[j] += d[i];
    int max1, res;
    res = 0;
    max1 = m;
    for(i = 1; i <= m; i++)
        if(res < d[i])
        {
            res = d[i];
            max1 = i;
        }
    cout << max1 << ' ' << res << '\n';
    if(res == 0) exit(0);
    for(i = 1; i <= n; i++)
        if(max1 % a[i] == 0) cout << i << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, a[1000004], d[1000004];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("bdnt.inp", "r", stdin);
    //freopen("bdnt.out", "w", stdout);
    cin >> n >> m;
    int i, j;
    for(i = 1; i <= n; i++) cin >> a[i];
    for(i = 1; i <= m; i++) d[i] = 0;
    for(i = 1; i <= n; i++)
        if(a[i] <= m) d[a[i]]++;
    for(i = m; i > 0; i--)
        if(d[i])
            for(j = i + i; j <= m; j += i) d[j] += d[i];
    int max1, res;
    max1 = res = 0;
    for(i = 1; i <= m; i++)
        if(res < d[i])
        {
            res = d[i];
            max1 = i;
        }
    cout << max1 << ' ' << res << '\n';
    if(res == 0) exit(0);
    for(i = 1; i <= n; i++)
        if(max1 % a[i] == 0) cout << i << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, a[1000004], d[1000004], k[1000004];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("bdnt.inp", "r", stdin);
    //freopen("bdnt.out", "w", stdout);
    cin >> n >> m;
    int i, j;
    for(i = 1; i <= n; i++) cin >> a[i];
    for(i = 1; i <= m; i++) d[i] = 0;
    for(i = 1; i <= n; i++)
        if(a[i] <= m) d[a[i]]++;
    for(i = 1; i <= m; i++) k[i] = d[i];
    for(i = 1; i <= m / 2; i++)
        if(d[i] != 0)
            for(j = i + i; j <= m; j += i)
                k[j] += k[i];
    int res, max1;
    res = max1 = 0;
    for(i = 1; i <= m; i++)
        if(res < k[i])
        {
            res = k[i];
            max1 = i;
        }
    cout << max1 << ' ' << res << '\n';
    if(max1 == 0) exit(0);
    for(i = 1; i <= n; i++)
        if(max1 % a[i] == 0) cout << i << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, a[1000004], d[1000004];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("bdnt.inp", "r", stdin);
    //freopen("bdnt.out", "w", stdout);
    cin >> n >> m;
    int i, j;
    for(i = 1; i <= n; i++) cin >> a[i];
    for(i = 1; i <= m; i++) d[i] = 0;
    for(i = 1; i <= n; i++)
        if(a[i] <= m) d[a[i]]++;
    for(i = m; i > 0; i--)
        if(d[i])
            for(j = i + i; j <= m; j += i) d[j] += d[i];
    int max1, res;
    res = 0;
    max1 = 1;
    for(i = 1; i <= m; i++)
        if(res < d[i])
        {
            res = d[i];
            max1 = i;
        }
    cout << max1 << ' ' << res << '\n';
    if(res == 0) exit(0);
    for(i = 1; i <= n; i++)
        if(max1 % a[i] == 0) cout << i << ' ';
    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;

using n_pos = pair<long long, long long>;

n_pos ary[1000005];
vector<n_pos>num_count[1000005];
long long num_factor[1000005];

bool compare(n_pos a, n_pos b)
{
	return a.second < b.second;
}

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> ary[i].first;
		ary[i].second = i;
		if (ary[i].first <= m)
			num_count[ary[i].first].push_back(ary[i]);
	}

	for(int i=1;i<=m;i++)
		for (int j = 1; j * i <= m; j++)
			if(!num_count[i].empty())
				num_factor[j * i] += num_count[i].size();
	long long k_max = 0;
	long long l = 1;
	for (int i = 1; i <= m; i++)
		if (num_factor[i] >= k_max)
		{
			k_max = num_factor[i];
			l = i;
		}
	vector<n_pos>ans;
	for (int i = 1; i <= m; i++)
		if (l % i == 0)
			ans.insert(ans.end(), num_count[i].begin(), num_count[i].end());
	sort(ans.begin(), ans.end(), compare);
	cout << l << ' ' << k_max << endl;
	for (auto c : ans)
		cout << c.second << ' ';
	return 0;
}


#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;

pair<long long,long long> ary[1000005];

bool compare(pair<long long, long long>a, pair<long long, long long>b)
{
	return a.first < b.first;
}

bool compare_pos(pair<long long, long long>a, pair<long long, long long>b)
{
	return a.second < b.second;
}

long long gcd(long long a, long long b)
{
	long long r = a % b;
	while (r)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

int main()
{
	long long n, m;
	cin >> n >> m;
	long long l;
	for (int i = 1; i <= n; i++)
	{
		cin >> ary[i].first;
		ary[i].second = i;
	}
	sort(ary + 1, ary + n + 1, compare);
	if(n==1)
		if (ary[1].first > m)
		{
			cout << 1 << ' ' << 0 << endl;
			cout << endl;
			return 0;
		}
		else
		{
			cout << ary[1].first << ' ' << 1 << endl;
			cout << ary[1].second << endl;
			return 0;
		}
	int len;
	l = lcm(ary[1].first, ary[2].first);
	vector<pair<long long, long long>>ans;
	ans.push_back(ary[1]);
	for (len = 2; ary[len].first <= m && len <= n; len++)
	{
		long long tmp = lcm(l, ary[len].first);
		if (tmp > m)
			continue;
		else
		{
			l = tmp;
			ans.push_back(ary[len]);
		}
	}
	sort(ans.begin(), ans.end(), compare_pos);
	cout << l << ' ' << ans.size() << endl;
	for (auto c : ans)
		cout << c.second << ' ';
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;

typedef pair<long long, long long> n_pos;;

n_pos ary[1000005];
vector<n_pos>num_count[1000005];
long long num_factor[1000005];

bool compare(n_pos a, n_pos b)
{
	return a.second < b.second;
}

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> ary[i].first;
		ary[i].second = i;
		if (ary[i].first <= m)
			num_count[ary[i].first].push_back(ary[i]);
	}

	for(int i=1;i<=m;i++)
		for (int j = 1; j * i <= m; j++)
			if(!num_count[i].empty())
				num_factor[j * i] += num_count[i].size();

	long long k_max = 0;
	long long l = 1;
	for (int i = 1; i <= m; i++)
		if (num_factor[i] > k_max)
		{
			k_max = num_factor[i];
			l = i;
		}
	vector<n_pos>ans;
	for (int i = 1; i <= m; i++)
		if (l % i == 0)
			ans.insert(ans.end(), num_count[i].begin(), num_count[i].end());
	sort(ans.begin(), ans.end(), compare);
	cout << l << ' ' << k_max << endl;
	for (int i=0;i<=ans.size();i++)
		cout << ans[i].second << ' ';
	return 0;
}