// http://codeforces.com/problemset/problem/246/D

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

#define ll long long
#define eps 1e-10
#define fi first
#define se second
#define MOD1 1000000007LL
#define MOD 1000000009LL
#define p1 53
#define se second
#define inf 20000000000LL
#define pb push_back
#define mp make_pair
#define maxn 300005

ll gcd1(ll a, ll b) {
    if (a == 0)
        return b;
    return gcd1(b % a, a);
}

ll modx(ll base, ll ex)
{
    ll ans = 1LL, val = base;
    while(ex > 0LL)
    {
        if(ex&1LL)
            ans = (ans*val)%MOD;
        val = (val*val)%MOD;
        ex = ex>>1LL;
    }
    return ans;
}

int color[maxn];
int cnt[maxn];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m;

    cin >> n >> m;

    for (int i = 1; i < maxn; i++)
        cnt[i] = -1;

    int maxx = INT_MIN;
    for (int i = 1; i <= n; i++) {
        cin >> color[i];
        cnt[color[i]] = 0;
        maxx = max(maxx, color[i]);
    }

    int x, y, ans = INT_MIN, cl = INT_MAX;
    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        if (color[x] != color[y]) {
            cnt[color[x]]++;
            cnt[color[y]]++;
        }
    }

    for (int i = 1; i <= maxx; i++) {
        if (cnt[i] > ans) {
            ans = cnt[i];
            cl = i;
        }
        else if (cnt[i] == ans)
            cl = min(cl, i);
    }

    cout << cl << endl;

    return 0;
}


// http://codeforces.com/problemset/problem/246/D

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

#define ll long long
#define eps 1e-10
#define fi first
#define se second
#define MOD1 1000000007LL
#define MOD 1000000009LL
#define p1 53
#define se second
#define inf 20000000000LL
#define pb push_back
#define mp make_pair
#define maxn 300005

ll gcd1(ll a, ll b) {
    if (a == 0)
        return b;
    return gcd1(b % a, a);
}

ll modx(ll base, ll ex)
{
    ll ans = 1LL, val = base;
    while(ex > 0LL)
    {
        if(ex&1LL)
            ans = (ans*val)%MOD;
        val = (val*val)%MOD;
        ex = ex>>1LL;
    }
    return ans;
}

int color[maxn];
set<int> v[maxn];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m;

    cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        cin >> color[i];
        v[i].insert(color[i]);
    }

    int x, y;
    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        v[x].insert(color[y]);
        v[y].insert(color[x]);
    }

    int ans = INT_MIN, cl = INT_MAX;
    for (int i = 1; i <= n; i++) {
        int sz = v[i].size();
        if (sz - 1 > ans) {
            ans = sz - 1;
            cl = color[i];
        }
        if (sz - 1 == ans)
            cl = min(cl, color[i]);
    }

    cout << cl << endl;

    return 0;
}


// http://codeforces.com/problemset/problem/246/D

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

#define ll long long
#define eps 1e-10
#define fi first
#define se second
#define MOD1 1000000007LL
#define MOD 1000000009LL
#define p1 53
#define se second
#define inf 20000000000LL
#define pb push_back
#define mp make_pair
#define maxn 300005

ll gcd1(ll a, ll b) {
    if (a == 0)
        return b;
    return gcd1(b % a, a);
}

ll modx(ll base, ll ex)
{
    ll ans = 1LL, val = base;
    while(ex > 0LL)
    {
        if(ex&1LL)
            ans = (ans*val)%MOD;
        val = (val*val)%MOD;
        ex = ex>>1LL;
    }
    return ans;
}

int color[maxn];
int cnt[maxn];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m;

    cin >> n >> m;

    for (int i = 1; i < maxn; i++)
        cnt[i] = -1;

    int maxx = INT_MIN;
    for (int i = 1; i <= n; i++) {
        cin >> color[i];
        cnt[color[i]] = 0;
        maxx = max(maxx, color[i]);
    }

    int x, y, ans = INT_MIN, cl = INT_MAX;
    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        if (color[x] != color[y]) {
            cnt[color[x]]++;
            cnt[color[y]]++;
        }
    }

    for (int i = 1; i <= maxx; i++) {
        if (cnt[i] > ans) {
            ans = cnt[i];
            cl = i;
        }
        else if (cnt[i] == ans && cnt[i] != -1)
            cl = min(cl, i);
    }

    cout << cl << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int ma=1e5+5;
set<int> S[ma];
int col[ma];
int has[ma];
//you cant compare size with negative number

int main()
{
	int n,m;
	cin>>n>>m;
	memset(has,0,sizeof(has));
	for(int i=1;i<=n;i++)
	{
		cin>>col[i];
		has[col[i]]=1;
	}
		int a,b;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		if(col[a]!=col[b])
		{
			//cout<<col[a]<<" "<<col[b]<<"ran"<<endl;
			S[col[a]].insert(col[b]);
			S[col[b]].insert(col[a]);
		}
	}
	int mx=-1;
	int p=-1;
	for(int i=ma;i>=0;i--)
	{
		int t=S[i].size();
		if(  has[i] && t>=mx)
		{
			p=i;
			mx=S[i].size();
		}
	}
	cout<<p<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int ma=1e5+5;
vector<int>G[ma];
map<int,vector<int> >cv;
int col[ma];
int has[ma];
int main()
{

  int n,m;
  cin>>n>>m;
  //int mc=0;
  for(int i=1;i<=n;i++)
  {
    cin>>col[i];
  //  mc=max(mc,col[i]);
    cv[col[i]].pb(i);
  }
  int a,b;
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    G[a].pb(b);
    G[b].pb(a);
  }
int ans=-1,flag;
  for(auto it:cv)
  {
    int c=it.first;
    int sum=0;
    for(auto i:it.second)
    {
      for(auto p:G[i])
      {
        if(col[p]!=c)
          if(!has[col[p]])
          {
            sum++;
            has[col[p]]=1;
          }
      }
    }
    if(ans<sum)
    {
      ans=sum;
      flag=c;
    }
    memset(has,0,sizeof(has));
  }
  cout<<flag<<endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int ma=1e5+5;
vector<int>G[ma];
map<int,vector<int> >cv;
int col[ma];
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)
  {
    cin>>col[i];
    cv[col[i]].pb(i);
  }
  int a,b;
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    G[a].pb(b);
    G[b].pb(a);
  }
int ans=0,flag;
  for(auto it:cv)
  {
    int c=it.first;
    int sum=0;
    for(auto i:it.second)
    {
      for(auto p:G[i])
      {
        if(col[p]!=c)
          sum++;
      }
    }
    ans=max(ans,sum);
    if(ans==sum)
      flag=c;
  }
  cout<<flag<<endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int ma=1e5+5;
vector<int>G[ma];
map<int,vector<int> >cv;
int col[ma];
int has[ma];
int main()
{

  int n,m;
  cin>>n>>m;
  //int mc=0;
  for(int i=1;i<=n;i++)
  {
    cin>>col[i];
  //  mc=max(mc,col[i]);
    cv[col[i]].pb(i);
  }
  int a,b;
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    G[a].pb(b);
    G[b].pb(a);
  }
int ans=0,flag;
  for(auto it:cv)
  {
    int c=it.first;
    int sum=0;
    for(auto i:it.second)
    {
      for(auto p:G[i])
      {
        if(col[p]!=c)
          if(!has[col[p]])
          {
            sum++;
            has[col[p]]=1;
          }
      }
    }
    if(ans<sum)
    {
      ans=sum;
      flag=c;
    }
    memset(has,0,sizeof(has));
  }
  cout<<flag<<endl;
  return 0;
}


          /***********BISMILLAHIR RAHMANIR RAHIM****
        ************NAHID AL-ASIB*********************
             ********************************/
#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int clr[mx],u,v,n,m,ans,ans_clr;
set<int>cnt[mx];
bool flag[mx];

int main()
{
      cin>>n>>m;
      memset(flag,0,sizeof(flag));
      for(int i=1;i<=n;i++)
      {
          scanf("%d",&clr[i]);
          flag[clr[i]]=1;
      }
      ans=0;
      ans_clr=mx;
      for(int i=0;i<m;i++)
      {
           scanf("%d%d",&u,&v);
           if(clr[u]!=clr[v])
           {
                cnt[clr[u]].insert(clr[v]);
                cnt[clr[v]].insert(clr[u]);
           }
      }

      for(int i=1;i<mx;i++)
      {
           int k=cnt[i].size();
           if(k>ans and flag[i]) {ans=k;ans_clr=i;}
           else if(k==ans and flag[i]){ans_clr=min(i,ans_clr);}
      }
      cout<<ans_clr<<endl;
      return 0;
}


/*Hints:Use Set to keep track with each colour.Handle the situation
that neighbours and node has same colour.Remember you have to
count the result for sum of total no.of cardinality for the
whole graph,not for a node.*/

#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int n,m,c[mx],ans,cardinality,sig[mx];
set<int>clr[mx];

int main()
{
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++) scanf("%d",&c[i]),sig[c[i]]=1;
        for(int i=0;i<m;i++)
        {
               int u,v;
               scanf("%d%d",&u,&v);
               if(c[u]!=c[v]) clr[c[u]].insert(c[v]),clr[c[v]].insert(c[u]);
        }

        ans=0;
        cardinality=mx;
        for(int i=1;i<100001;i++)
        {
              if(!sig[i]) continue;
              if(clr[i].size()>ans) ans=clr[i].size(),cardinality=i;
              else if(clr[i].size()==ans) cardinality=min(i,cardinality);
        }
        printf("%d\n",cardinality);
        return 0;
}


/*Hints:Use Set to keep track with each node*/

#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int n,m,c[mx],ans,cardinality;
set<int>clr[mx];

int main()
{
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++) scanf("%d",&c[i]);
        for(int i=0;i<m;i++)
        {
               int u,v;
               scanf("%d%d",&u,&v);
               clr[u].insert(c[v]);
               clr[v].insert(c[u]);
        }

        ans=0;
        cardinality=mx;
        for(int i=1;i<=n;i++)
        {
              if(clr[i].size()>ans) ans=clr[i].size(),cardinality=c[i];
              else if(clr[i].size()==ans) cardinality=min(c[i],cardinality);
        }
        printf("%d\n",cardinality);
        return 0;
}


/*Hints:Use Set to keep track with each colour.Handle the situation
that neighbours and node has same colour.Remember you have to
count the result for sum of total no.of cardinality for the
whole graph,not for a node.*/

#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int n,m,c[mx],ans,cardinality,sig[mx],k;
set<int>clr[mx];

int main()
{
        scanf("%d%d",&n,&m);
        k=-1;
        for(int i=1;i<=n;i++) scanf("%d",&c[i]),sig[c[i]]=1,k=max(k,c[i]);
        for(int i=0;i<m;i++)
        {
               int u,v;
               scanf("%d%d",&u,&v);
               if(c[u]!=c[v]) clr[c[u]].insert(c[v]),clr[c[v]].insert(c[u]);
        }

        ans=0;
        cardinality=mx;
        for(int i=1;i<=k;i++)
        {
              if(!sig[i]) continue;
              if(clr[i].size()>ans) ans=clr[i].size(),cardinality=i;
              else if(clr[i].size()==ans) cardinality=min(cardinality,i);
        }
        printf("%d\n",cardinality);
        return 0;
}


          /***********BISMILLAHIR RAHMANIR RAHIM****
        ************NAHID AL-ASIB*********************
             ********************************/
#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int clr[mx],u,v,n,m,ans,ans_clr;
set<int>cnt[mx];
bool flag[mx];

int main()
{
      cin>>n>>m;
      memset(flag,0,sizeof(flag));
      for(int i=1;i<=n;i++)
      {
          scanf("%d",&clr[i]);
          flag[clr[i]]=1;
      }
      ans=0;
      ans_clr=mx;
      for(int i=0;i<m;i++)
      {
           scanf("%d%d",&u,&v);
           if(clr[u]!=clr[v])
           {
                cnt[clr[u]].insert(clr[v]);
                cnt[clr[v]].insert(clr[u]);
           }
      }

      for(int i=1;i<mx;i++)
      {
           int k=cnt[i].size();
           if(k>=ans and flag[i]) {ans=k;ans_clr=min(i,ans_clr);}
      }
      cout<<ans_clr<<endl;
      return 0;
}


/*Hints:Use Set to keep track with each node.Handle the situation
c[v]!=c[u].*/

#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int n,m,c[mx],ans,cardinality;
set<int>clr[mx];

int main()
{
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++) scanf("%d",&c[i]);
        for(int i=0;i<m;i++)
        {
               int u,v;
               scanf("%d%d",&u,&v);
               if(c[u]!=c[v]) clr[u].insert(c[v]),clr[v].insert(c[u]);
        }

        ans=0;
        cardinality=mx;
        for(int i=1;i<=n;i++)
        {
              if(clr[i].size()>ans) ans=clr[i].size(),cardinality=c[i];
              else if(clr[i].size()==ans) cardinality=min(c[i],cardinality);
        }
        printf("%d\n",cardinality);
        return 0;
}


          /***********BISMILLAHIR RAHMANIR RAHIM****
        ************NAHID AL-ASIB*********************
             ********************************/
#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int clr[mx],u,v,n,m,ans,ans_clr;
set<int>cnt[mx];

int main()
{
      cin>>n>>m;
      for(int i=1;i<=n;i++) scanf("%d",&clr[i]);
      ans=-mx;
      ans_clr=mx;
      for(int i=0;i<m;i++)
      {
           scanf("%d%d",&u,&v);
           if(clr[u]!=clr[v])
           {
                cnt[clr[u]].insert(clr[v]);
                cnt[clr[v]].insert(clr[u]);
           }
      }

      for(int i=1;i<mx;i++)
      {
           int k=cnt[i].size();
           if(k>ans) {ans=k;ans_clr=i;}
      }
      cout<<ans_clr<<endl;
      return 0;
}


/*Hints:Use Set to keep track with each colour.Handle the situation
that neighbours and node has same colour.Remember you have to
count the result for sum of total no.of cardinality for the
whole graph,not for a node.*/

#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int n,m,c[mx],ans,cardinality,sig[mx];
set<int>clr[mx];

int main()
{
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++) scanf("%d",&c[i]),sig[c[i]]=1;
        for(int i=0;i<m;i++)
        {
               int u,v;
               scanf("%d%d",&u,&v);
               if(c[u]!=c[v]) clr[c[u]].insert(c[v]),clr[c[v]].insert(c[u]);
        }

        ans=-1;
        cardinality=mx;
        for(int i=1;i<100001;i++)
        {
              if(!sig[i]) continue;
              if(clr[i].size()>ans) ans=clr[i].size(),cardinality=i;
        }
        printf("%d\n",cardinality);
        return 0;
}


/*Hints:Use Set to keep track with each colour.Handle the situation
that neighbours and node has same colour.Remember you have to
count the result for sum of total no.of cardinality for the
whole graph,not for a node.*/

#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int n,m,c[mx],ans,cardinality,sig[mx];
set<int>clr[mx];

int main()
{
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++) scanf("%d",&c[i]),sig[c[i]]=1;
        for(int i=0;i<m;i++)
        {
               int u,v;
               scanf("%d%d",&u,&v);
               if(c[u]!=c[v]) clr[c[u]].insert(c[v]),clr[c[v]].insert(c[u]);
        }

        ans=0;
        cardinality=mx;
        for(int i=1;i<100001;i++)
        {
              if(!sig[i]) continue;
              if(clr[i].size()>ans) ans=clr[i].size(),cardinality=i;
        }
        printf("%d\n",cardinality);
        return 0;
}


/*Hints:Use Set to keep track with each colour.Handle the situation
that neighbours and node has same colour.Remember you have to
count the result for sum of total no.of cardinality for the
whole graph,not for a node.*/

#include<bits/stdc++.h>
#define mx 100005

using namespace std;
int n,m,c[mx],ans,cardinality;
set<int>clr[mx];

int main()
{
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++) scanf("%d",&c[i]);
        for(int i=0;i<m;i++)
        {
               int u,v;
               scanf("%d%d",&u,&v);
               if(c[u]!=c[v]) clr[c[u]].insert(c[v]),clr[c[v]].insert(c[u]);
        }

        ans=0;
        cardinality=mx;
        for(int i=1;i<100001;i++)
        {
              if(clr[i].size()>ans) ans=clr[i].size(),cardinality=i;
              else if(clr[i].size()==ans) cardinality=min(i,cardinality);
        }
        printf("%d\n",cardinality);
        return 0;
}


// In the name of God.
// 23/02/2016
// 1394/12/11

#include <iostream>
#include <vector>

using namespace std;

typedef pair <int , int> pii;

const int N = 1000*100 + 10;
int colour[N], n, m, cnt[N];;
vector <int> G[N];
pii ans;

int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		colour[i] = v-1;
	}
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		G[--u].push_back(--v);
		G[v].push_back(u);
	}

	for(int i = 0 ; i < n; i++)
		for(int j = 0 ; j < G[i].size(); j++)
			if(colour[G[i][j]] != colour[i])
				cnt[colour[i]]++;

	for(int i = 0; i < N; i++)
		if(cnt[i] > ans.second)
			ans = make_pair(i+1 , cnt[i]);

	cout << ans.first;
}


// In the name of God.
// 23/02/2016
// 1394/12/11

// bad az tedad e ziadi WA, taze fahmidam soal ro bad fahmidam. :D

#include <iostream>
#include <vector>
#include <set>

using namespace std;

typedef pair <int , int> pii;

const int N = 1000*100 + 10;
int n, m, colour[N];
set <int> cnt[N];
vector <int> G[N];
pii ans;

int main()
{
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> colour[i];
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		G[--u].push_back(--v);
		G[v].push_back(u);
	}

	for(int i = 0 ; i < n; i++)
	{
		cnt[colour[i]].insert(colour[i]);
		for(int j = 0 ; j < int(G[i].size()); j++)
			cnt[colour[i]].insert(colour[G[i][j]]);
	}

	for(int i = 0 ; i < N; i++)
		if(int(cnt[i].size()) > ans.second)
			ans = make_pair(i , int(cnt[i].size()));

	cout << ans.first;
}


// In the name of God.
// 23/02/2016
// 1394/12/11

#include <iostream>
#include <vector>

using namespace std;

typedef pair <int , int> pii;

const int N = 1000*100 + 10;
int colour[N], n, m, cnt[N];;
vector <int> G[N];
pii ans;

int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		colour[i] = v-1;
	}
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		G[--u].push_back(--v);
		G[v].push_back(u);
	}

	for(int i = 0 ; i < n; i++)
		for(int j = 0 ; j < G[i].size(); j++)
			if(colour[G[i][j]] != colour[i])
				cnt[colour[i]]++;

	for(int i = N-1; i >= 0; i--)
		if(cnt[i] >= ans.second)
			ans = make_pair(i+1 , cnt[i]);

	cout << ans.first;
}


// In the name of God.
// 23/02/2016
// 1394/12/11

#include <iostream>
#include <vector>

using namespace std;

typedef pair <int , int> pii;

const int N = 1000*100 + 10;
int colour[N], n, m, cnt[N];;
vector <int> G[N];
pii ans;

int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		colour[i] = v-1;
		ans.first = v;
	}
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		G[--u].push_back(--v);
		G[v].push_back(u);
	}

	for(int i = 0 ; i < n; i++)
		for(int j = 0 ; j < G[i].size(); j++)
			if(colour[G[i][j]] != colour[i])
				cnt[colour[i]]++;

	for(int i = 0; i < N; i++)
		if(cnt[i] > ans.second)
			ans = make_pair(i+1 , cnt[i]);

	cout << ans.first;
}


// In the name of God.
// 23/02/2016
// 1394/12/11

#include <iostream>
#include <vector>

using namespace std;

typedef pair <int , int> pii;

const int N = 1000*100 + 10;
int n, m, colour[N], cnt[N];
vector <int> G[N], vertice[N];
pii ans;

int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		vertice[v-1].push_back(i);
		colour[i] = v-1;
	}
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		G[--u].push_back(--v);
		G[v].push_back(u);
	}

	ans.second = -1;
	for(int i = 0 ; i < N; i++)
	{
		int cnt = 0;
		for(int j = 0 ; j < vertice[i].size(); j++)
		{
			int v = vertice[i][j];
			for(int k = 0; k < G[v].size(); k++)
				if(colour[G[v][k]] != i)
					cnt++;
		}
		if(ans.second < cnt && vertice[i].size())
				ans = make_pair(i+1 , cnt);
	}

	cout << ans.first;
}


// In the name of God.
// 23/02/2016
// 1394/12/11

#include <iostream>
#include <vector>

using namespace std;

typedef pair <int , int> pii;

const int N = 1000*100 + 10;
int colour[N], n, m, cnt[N];
vector <int> G[N];
bool mark[N];
pii ans;

int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

	cin >> n >> m;
	ans.second = -1;
	for(int i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		colour[i] = v-1;
		mark[v-1] = true;
		ans.first = v;
	}
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		G[--u].push_back(--v);
		G[v].push_back(u);
	}

	for(int i = 0 ; i < n; i++)
		for(int j = 0 ; j < G[i].size(); j++)
			if(colour[G[i][j]] != colour[i])
				cnt[colour[i]]++;

	for(int i = 0; i < N; i++)
		if(cnt[i] > ans.second && mark[i])
			ans = make_pair(i+1 , cnt[i]);

	cout << ans.first;
}


// In the name of God.
// 23/02/2016
// 1394/12/11

#include <iostream>
#include <vector>

using namespace std;

typedef pair <int , int> pii;

const int N = 1000*100 + 10;
int colour[N], n, m, cnt[N];
vector <int> G[N];
bool mark[N];
pii ans;

int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

	cin >> n >> m;
	ans.second = -1;
	for(int i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		colour[i] = v-1;
		mark[v-1] = true;
	}
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		G[--u].push_back(--v);
		G[v].push_back(u);
	}

	for(int i = 0 ; i < n; i++)
		for(int j = 0 ; j < G[i].size(); j++)
			if(colour[G[i][j]] != colour[i])
				cnt[colour[i]]++;

	for(int i = 0; i < N; i++)
		if(cnt[i] > ans.second && mark[i])
			ans = make_pair(i+1 , cnt[i]);

	cout << ans.first;
}


#include <bits/stdc++.h>
using namespace std;
int arr[100001];
vector<int>s[100001];
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
   }
   int ans=-1,k=0;
   while(m--)
   {
       int a,b;
       cin>>a>>b;
       if(arr[a]!=arr[b]){
       s[arr[a]].push_back(arr[b]);
       int x = s[arr[a]].size();
       if(x>ans)
       {
           ans=x;
           k=arr[a];
       }
       else if(x==ans){k=min(k,arr[a]);}
       s[arr[b]].push_back(arr[a]);
       x = s[arr[b]].size();
       if(x>ans)
       {
           ans=x;
           k=arr[b];
       }
       else if(x==ans){k=min(k,arr[b]);}}
   }
   cout<<k<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
map<int,set<int> >mip;
int arr[100001];
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   for(int i=1;i<=n;i++)cin>>arr[i];
   while(m--)
   {
       int a,b;
       cin>>a>>b;
       if(arr[a]!=arr[b])
       {
           mip[arr[a]].insert(arr[b]);
           mip[arr[b]].insert(arr[a]);
       }
   }
   int cnt=0;
   int ans=-1;
   for(map<int,set<int> >::iterator it=mip.begin();it!=mip.end();it++)
   {
       if(it->second.size()>cnt)
       {
           ans=it->first;
           cnt=it->second.size();
       }
   }
   cout<<ans<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
map<int,set<int> >mip;
int arr[100001];
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   set<int>s;
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
       mip[arr[i]]=s;
   }
   while(m--)
   {
       int a,b;
       cin>>a>>b;
       if(arr[a]!=arr[b])
       {
           mip[arr[a]].insert(arr[b]);
           mip[arr[b]].insert(arr[a]);
       }
   }
   int cnt=-1;
   int ans=-1;
   for(map<int,set<int> >::iterator it=mip.begin();it!=mip.end();it++)
   {
       if((int)it->second.size()>cnt)
       {
           ans=it->first;
           cnt=it->second.size();
       }
   }
   cout<<ans<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
int arr[100001];
set<int>s[100001];
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
   }
   while(m--)
   {
       int a,b;
       cin>>a>>b;
           s[arr[a]].insert(arr[b]);
           s[arr[b]].insert(arr[a]);
   }
   int ans=-1,k=0;
   for(int i=1;i<=100000;i++)
   {
        int x = s[i].size();
        if(x>ans)
        {
            ans=s[i].size();
            k=i;
        }
   }
   cout<<k<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
int arr[100001];
set<int>s[100001];
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
   }
   int ans=-1,k=0;
   while(m--)
   {
       int a,b;
       cin>>a>>b;
       s[arr[a]].insert(arr[b]);
       int x = s[arr[a]].size();
       if(x>ans)
       {
           ans=x;
           k=arr[a];
       }
       else if(x==ans){k=min(k,arr[a]);}
       s[arr[b]].insert(arr[a]);
       x = s[arr[b]].size();
       if(x>ans)
       {
           ans=x;
           k=arr[b];
       }
       else if(x==ans){k=min(k,arr[b]);}
   }
   cout<<k<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
int arr[100001];
set<int>s[100001];
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
   }
   while(m--)
   {
       int a,b;
       cin>>a>>b;
       if(arr[a]!=arr[b])
       {
           s[arr[a]].insert(arr[b]);
           s[arr[b]].insert(arr[a]);
       }
   }
   int ans=-1,k=0;
   for(int i=1;i<=100000;i++)
   {
        int x = s[i].size();
        if(x>ans)
        {
            ans=s[i].size();
            k=i;
        }
   }
   cout<<k<<endl;
   return 0;
}


#include<bits/stdc++.h>
using namespace std ;
long long ans , mx , a[100001], l , r , n , m , used[10001] , A[100001];
vector<long long> verr[100001];
void Rec(long long v){
     used[v] = 1;
     //cout <<   - 2;
     for(int i =  0;  i< verr[v].size();i++){
         long long to = verr[v][i];
         if(a[to]  != a[v])
            A[to]++;

         if(used[to] == 0)
            Rec(to);
     }
}
int main(){
    cin>>n>>m;
    //cout << n<<'\n';
    int i ;
    for(i=1;i<=n;i++)
        cin>>a[i];

    for(i=1;i<=m;i++){
        cin>>l>>r;
        verr[l].push_back(r);
        verr[r].push_back(l);
    }

    for(i=1;i<=n;i++){
        //A[i] = 1 ;
            //cout << - 1<<'\n';
        if(used[i] == 0)
            Rec(i);
    }
    ans = 100000;
    for(i=1;i<=n;i++){
       // cout << A[i]<<" ";
      if(A[ans] < A[a[i]])
            ans = a[i];

      if(A[ans] == A[a[i]])
        ans = min(ans , a[i]);
    }
    cout << ans;
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int  MOD=1000000007;
int lowbit(int n){
    int res=1;
    while((n & res) == 0){
        res=(res << 1);
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    int sum,limit;
    cin>>sum>>limit;
    set<int> s;
    for(int i=limit;i>=1 && sum>0;i--){
        int x=lowbit(i);
        if(x<=sum) {
            sum-=x;
            s.insert(x);
        }
    }
   if  (sum==0){
       cout<<s.size()<<"\n";
       for(int x : s) {
           cout<<x<<" ";
        }

   } else {
       cout<<"-1";
    }

    return 0;

}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int  MOD=1000000007;
int lowbit(int n){
    int res=1;
    while((n & res) == 0){
        res=(res << 1);
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    int sum,limit;
    cin>>sum>>limit;
    set<int> s;
    for(int i=limit;i>=1 && sum>0;i--){
        int x=lowbit(i);
        if(x<=sum) {
            sum-=x;
            s.insert(i);
        }
    }
   if  (sum==0){
       cout<<s.size()<<"\n";
       for(int x : s) {
           cout<<x<<" ";
        }

   } else {
       cout<<"-1";
    }

    return 0;

}


#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

int lowBit(int x) {
  int n = 1;
  for (int t = x; (t&1) == 0; t>>=1) {
    n++;
  }
  return 1<<(n-1);
}

int main() {
  int sum, limit;
  cin >> sum >> limit;

  int n = 0;
  for (int t = limit; t != 0; t>>=1) n++;

  vector <int> memo[n];
  for (int i = 1; i <= limit; i++) {
    int n = 1;
    for (int t = i; (t&1) == 0; t>>=1) n++;
    memo[n-1].push_back(i);
  }

  // for (int i = 0; i < n; i++) {
  //   for (int j = 0; j < memo[i].size(); j++) {
  //     cout << memo[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  int dig[n];
  for (int i = 0; i < n; i++) {
    dig[i] = (1<<i);
  }
  int dp[n][sum+1];
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i <= memo[0].size(); i++) {
    dp[0][i] = memo[0].size()-i;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= sum; j++) {
      if (dp[i-1][j] >= 0) {
    dp[i][j] = memo[i].size();
      }else if (j < dig[i] || dp[i][j-dig[i]] <= 0) {
    dp[i][j] = -1;
      }else {
    dp[i][j] = dp[i][j-dig[i]]-1;
      }
    }
  }

  if (dp[n-1][sum] == -1) {
    cout << -1 << endl;
    return 0;
  }

  vector <int> ans;
  int j = sum;
  for (int i = n-1; i >= 0; i--) {
    int t = memo[i].size()-dp[i][j];
    for (int k = 0; k < t; k++) ans.push_back(memo[i][k]);
    j -= dig[i]*t;
  }

  if (ans.size() > 100000) {
    cout << -1 << endl;
    return 0;
  }

  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    printf ("%d ", ans[i]);
  }
  cout << endl;
}


#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool pairCompare(const pair<int, int> a, const pair<int, int> b) {
  return a.first > b.first;
}

int main() {
  int sum, limit;
  cin >> sum >> limit;

  vector <pair<int, int> > a(limit);
  for (int i = 1; i <= limit; i++) a[i-1]=make_pair((i & -i), i);

  vector <int> ans;
  sort(a.begin(), a.end(), pairCompare);
  for (int i = 0; i < limit; i++) {
    if (a[i].first > sum) continue;
    sum -= a[i].first;
    ans.push_back(a[i].second);
  }

  if (sum) {
    cout << -1 << endl;
  }else {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }

  return 0;
}


#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main() {
  int sum, limit;
  cin >> sum >> limit;

  vector <pair<int, int> > a(limit);
  for (int i = 1; i <= limit; i++) a[i-1]=make_pair((i & -i), i);

  vector <int> ans;
  sort(a.begin(), a.end());
  for (int i = 0; i < limit; i++) {
    if (a[i].first > sum) continue;
    sum -= a[i].first;
    ans.push_back(a[i].second);
  }

  if (sum) {
    cout << -1 << endl;
  }else {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }

  return 0;
}


#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

int lowBit(int x) {
  int n = 1;
  for (int t = x; (t&1) == 0; t>>=1) {
    n++;
  }
  return 1<<(n-1);
}

int main() {
  int sum, limit;
  cin >> sum >> limit;

  int n = 0;
  for (int t = limit; t != 0; t>>=1) n++;

  vector <int> memo[n];
  for (int i = 1; i <= limit; i++) {
    int n = 1;
    for (int t = i; (t&1) == 0; t>>=1) n++;
    memo[n-1].push_back(i);
  }

  // for (int i = 0; i < n; i++) {
  //   for (int j = 0; j < memo[i].size(); j++) {
  //     cout << memo[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  int dp[n][sum+1];
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i <= memo[0].size(); i++) {
    dp[0][i] = memo[0].size()-i;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= sum; j++) {
      if (dp[i-1][j] >= 0) {
    dp[i][j] = memo[i].size();
      }else if (j < (1<<i) || dp[i][j-(1<<i)] <= 0) {
    dp[i][j] = -1;
      }else {
    dp[i][j] = dp[i][j-(1<<i)]-1;
      }
    }
  }

  if (dp[n-1][sum] == -1) {
    cout << -1 << endl;
    return 0;
  }

  vector <int> ans;
  int j = sum;
  for (int i = n-1; i >= 0; i--) {
    int t = memo[i].size()-dp[i][j];
    for (int k = 0; k < t; k++) ans.push_back(memo[i][k]);
    j -= (1<<i)*t;
  }

  if (ans.size() > 100000) {
    cout << -1 << endl;
    return 0;
  }

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


#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
  int sum, limit;
  vector<int> res;
  vector<int> b[33];

  cin >> sum >> limit;
  for (int i = 1; i <= limit; ++i) {
    for (int j = 0; j < 32; ++j) {
      if (i & (1 << j)) {
        b[j].push_back(i);
        break;
      }
    }
  }
  for (int i = 32; i >= 0 && sum > 0; --i) {
    int t = sum / (1 << i);
    for (int j = 0; j < min(t, (int)b[i].size()); ++j) {
      res.push_back(b[i][j]);
    }
    //printf("sum = %d\n", sum);
    sum -= min(t, (int)b[i].size()) * (1 << i);
  }

  if (sum) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", (int)res.size());
  for (auto& ele : res) {
    printf("%d ", ele);
  }
  cout << endl;

  return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
  int sum, limit;
  bool flag = false;
  vector<int> res;

  cin >> sum >> limit;
  for (int i = 0; i < 32; ++i) {
    if (sum & (1 << i)) {
      if ((1 << i) > limit) {
        flag = true;
        break;
      } else {
        res.push_back(1 << i);
      }
    }
  }
  if (flag) {
    printf("-1\n");
  }
  printf("%d\n", (int)res.size());
  for (auto& ele : res) {
    printf("%d ", ele);
  }
  cout << endl;

  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

#ifdef DK
const int MAX = 111;
#else
const int MAX = 1e5 + 11;
#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  DRII(N, M);
  vector<int> res;
  int64_t r = 0;
  REPN(i, 1, M) {
    if ((i & 1) && (r < N)) {
      res.PB(i);
      r++;
    }
  }
  REPN(i, 1, M) {
    if (!(i & 1) && (i & (1 << 1)) && r < N) {
      res.PB(i);
      r += 2;
    }
  }
  if (r == N) {
    printf("%d\n", SZ(res));
    REP(i, SZ(res)) printf("%d ", res[i]);
  } else {
    printf("-1");
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

#ifdef DK
const int MAX = 111;
#else
const int MAX = 1e5 + 11;
#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  DRII(N, M);
  vector<int> res;
  int64_t r = 0;
  REPN(i, 1, M) {
    if (i & 1){
      res.PB(i);
      r++;
    }
  }
  REPN(i, 1, M) {
    if (!(i & 1) && (i & (1 << 1)) && r < N) {
      res.PB(i);
      r += 2;
    }
  }
  if (r == N) {
    printf("%d\n", SZ(res));
    REP(i, SZ(res)) printf("%d ", res[i]);
  } else {
    printf("-1");
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <fstream>

#define REP(I, N) for (int I = 0; I < (N); ++I)
#define PER(I, N) for (int I = (N); I >= 0; --I)
#define PERR(I, A, B) for (int I = (A); I >= (B); --I)
#define REPP(I, A, B) for (int I = (A); I <  (B); ++I)
#define REPN(I, A, B) for (int I = (A); I <= (B); ++I)
#define REPC(I, A, C) for (int I = (A); (C); ++I)
#define REPPP(I, A, B, C) for (int I = (A); I <  (B); I += C)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define RIIII(X, Y, Z, W) scanf("%d%d%d%d", &(X), &(Y), &(Z), &(W))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRIIII(X, Y, Z, W) int X, Y, Z, W; scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define RS(X) scanf("%s", (X))
#define LEN(X) int(strlen(X))
#define SZ(X) int((X).size())
#define SUM(X, N) accumulate(X, X + (N), 0)
#define MS0(X) memset((X), 0, sizeof(X))
#define MSI(X) memset((X), 0xFF, sizeof(X))
#define F first
#define S second
#define MP make_pair
#define PB push_back

#ifdef DK
const int MAX = 111;
#else
const int MAX = 1e5 + 11;
#endif

using namespace std;

int main() {
#ifdef DK
  freopen("in.txt", "r", stdin);
#endif
  DRII(N, M);
  vector<int> res;
  int64_t r = 0;
  PERR(i, M, 1) {
    int t = 0;
    REP(j, 31) {
      if ((1 << j) & i) {
        t = (1 << j);
        break;
      }
    }
    if (t != 0)
    if (r + t <= N) {
      r += t;
      res.PB(i);
    }
  }
  if (r == N) {
    printf("%d\n", SZ(res));
    REP(i, SZ(res)) printf("%d ", res[i]);
  } else {
    printf("-1");
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = (int) 2e5 + 7;

vector<int> ans;
int sum, lim;

int main() {
  scanf("%d%d", &sum, &lim);
  for (int i = lim; i > 0; --i) {
    int low = (i & -i);
    if (sum >= low) {
      sum -= low;
      ans.push_back(i);
    }
  }
  if (sum) {
    printf("-1");
    return 0;
  }
  printf("%d\n", ans.size());
  for (auto i : ans)
    printf("%d ", i);

  return 0;
}


#include <iostream>
#include <string>

using namespace std;

bool used[100001];
int sum, limit;
int numAns;

bool Assign(int k) {
    if (k < 0) {
        return false;
    }

    int num = 1 << k;
    while (num <= limit && used[num]) {
        num += 1 << (k + 1);
    }

    if (num > limit) {
        if (!Assign(k - 1)) {
            return false;
        }
        if (!Assign(k - 1)) {
            return false;
        }
    } else {
        used[num] = true;
        numAns++;
    }

    return true;
}

int main() {
    cin >> sum >> limit;

    for (int k = 0; sum != 0; k++, sum >>= 1) {
        if ((sum & 1) == 1) {
            if (!Assign(k)) {
                cout << -1 << endl;
                return 1;
            }
        }
    }

    cout << numAns << endl;

    for (int i = 0, j = 0; i <= limit; i++) {
        if (used[i]) {
            cout << (j == 0 ? "" : " ") << i;
            j++;
        }
    }

    cout << endl;
}


#include <iostream>
#include <string>

using namespace std;

bool used[100001];
int sum, limit;
int numAns;

bool Assign(int k) {
    if (k < 0) {
        return false;
    }

    int num = 1 << k;
    while (num <= limit && used[num]) {
        num += 1 << (k + 1);
    }

    if (num > limit) {
        if (!Assign(k - 1)) {
            return false;
        }
        if (!Assign(k - 1)) {
            return false;
        }
    } else {
        used[num] = true;
        numAns++;
    }

    return true;
}

int main() {
    cin >> sum >> limit;

    for (int k = 0; sum != 0; k++, sum >>= 1) {
        if ((sum & 1) == 1) {
            if (!Assign(k)) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << numAns << endl;

    for (int i = 0, j = 0; i <= limit; i++) {
        if (used[i]) {
            cout << (j == 0 ? "" : " ") << i;
            j++;
        }
    }

    cout << endl;
}


#include<bits/stdc++.h>

#define lowbit(x) (x & (-x))
#define ll long long
#define pb push_back

using namespace std;
int main()
{
    ll sum,limit;
    vector<int> S;
    cin>>sum>>limit;
    for(int i = limit;(sum>0) && (i>0);--i)
    {
        if((sum - lowbit(i))<0)   //If you encounter negative values ,then skip
        continue;
        sum = sum - lowbit(i);
        S.pb(i);
    }
    if(sum) cout<<"-1";
    else
    {
        cout<<S.size()<<"\n";
        for(int i=0;i<S.size();++i)
        cout<<S[i]<<" ";
    }
    return 0;
}


//Child and Set by a.k.a skull_crusher
/*Algo :- Odd numbers have lowbit as 1 . Try to achieve the sum using only odd numbers , if it is not possible
          then try using the even numbers . Even then , if it is not possible then print -1  */
#include<bits/stdc++.h>
#define lowbit(x) (x & (-x))
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll sum,limit;
    vector<int> S;
    cin>>sum>>limit;
    for(int i = limit;(sum>0) && (i>0);--i)
    {
        if((sum - lowbit(i))<0)   //If you encounter negative values ,then skip
        continue;
        sum = sum - lowbit(i);
        S.pb(i);
    }
    if(sum) cout<<"-1";
    else
    {
        cout<<S.size()<<"\n";
        for(int i=0;i<S.size();++i)
        cout<<S[i]<<" ";
    }
    return 0;
}


#include <bits/stdtr1c++.h>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<ld> pt;

int cnt[1000];
vector<int> num[100];
int main() {
	ll sum, lim;
	cin >> sum >> lim;

	memset(cnt, 0, sizeof cnt);
	for (int i = 1; i <= lim; i++) {
		cnt[__builtin_ctz(i)]++;
		num[__builtin_ctz(i)].push_back(i);
	}

	vector<ll> S;
	for (int i = 0; (1LL << i) <= sum; i++) {
		ll bit = (1LL << i);
		if (!(bit&sum)) continue;

		if (cnt[i]) {
			S.push_back(bit);
			cnt[i]--;
		} else {
			int j = i-1;
			ll s = 0;

			while (s != bit && j >= 0) {
				while (!num[j].empty()) {
					S.push_back(num[j].back());
					num[j].pop_back();
					cnt[j]--;
					s += (1 << j);
					if (s == bit) break;
				}
				if (s == bit) break;
				j--;
			}

			if (j < 0) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	sort(S.begin(), S.end());
	cout << S.size() << endl;
	for (int i = 0; i < S.size(); i++) {
		cout << S[i] << " ";
	}
	cout << endl;
	return 0;
}


#include <bits/stdtr1c++.h>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<ld> pt;

int cnt[1000];
vector<int> num[100];
int main() {
	ll sum, lim;
	cin >> sum >> lim;

	memset(cnt, 0, sizeof cnt);
	for (int i = 1; i <= lim; i++) {
		cnt[__builtin_ctz(i)]++;
		num[__builtin_ctz(i)].push_back(i);
	}

	vector<ll> S;
	for (int i = 0; (1LL << i) <= sum; i++) {
		ll bit = (1LL << i);
		if (!(bit&sum)) continue;

		if (cnt[i]) {
			S.push_back(num[i].back());
			cnt[i]--;
			num[i].pop_back();
		} else {
			int j = i-1;
			ll s = 0;

			while (s != bit && j >= 0) {
				while (!num[j].empty()) {
					S.push_back(num[j].back());
					num[j].pop_back();
					cnt[j]--;
					s += (1 << j);
					if (s == bit) break;
				}
				if (s == bit) break;
				j--;
			}

			if (j < 0) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	sort(S.begin(), S.end());
	//int s = 0;
	cout << S.size() << endl;
	for (int i = 0; i < S.size(); i++) {
		cout << S[i] << " ";
		//s += (1 << __builtin_ctz(S[i]));
	}
	cout << endl;
	//cout << s << endl;
	return 0;
}


#include <bits/stdtr1c++.h>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<ld> pt;

int cnt[1000];
vector<int> num[100];
int main() {
	ll sum, lim;
	cin >> sum >> lim;

	memset(cnt, 0, sizeof cnt);
	for (int i = 1; i <= lim; i++) {
		cnt[__builtin_ctz(i)]++;
		num[__builtin_ctz(i)].push_back(i);
	}

	vector<ll> S;
	for (int i = 0; (1LL << i) <= sum; i++) {
		ll bit = (1LL << i);
		if (!(bit&sum)) continue;

		if (cnt[i]) {
			S.push_back(bit);
			cnt[i]--;
			num[i].pop_back();
		} else {
			int j = i-1;
			ll s = 0;

			while (s != bit && j >= 0) {
				while (!num[j].empty()) {
					S.push_back(num[j].back());
					num[j].pop_back();
					cnt[j]--;
					s += (1 << j);
					if (s == bit) break;
				}
				if (s == bit) break;
				j--;
			}

			if (j < 0) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	sort(S.begin(), S.end());
	//int s = 0;
	cout << S.size() << endl;
	for (int i = 0; i < S.size(); i++) {
		cout << S[i] << " ";
		//s += (1 << __builtin_ctz(S[i]));
	}
	cout << endl;
	//cout << s << endl;
	return 0;
}


#include <bits/stdc++.h>

unsigned low_bit ( unsigned x ) {
    unsigned answer;

    answer = 1;
    while ( (x&1) == 0 ) {
        answer <<= 1;
        x >>= 1;
    }

    return answer;
}

int main ( void ) {

    unsigned sum, limit, i;
    std::vector<unsigned> answer;
    std::vector<std::pair<unsigned, unsigned> > a;

    std::cin >> sum >> limit;

    for ( i = 1 ; i <= limit ; ++ i ) {
        a.push_back(std::make_pair(low_bit(i), i));
    }

    std::sort(a.begin(), a.end(), std::greater<std::pair<int, int> >());

    for ( i = limit ; i > 0 ; -- i ) {
        if ( low_bit(i) <= sum ) {
            sum -= low_bit(i);
            answer.push_back(i);
        }
    }

    if ( sum != 0 ) {
        std::cout << -1 << std::endl;
    }
    else {
        std::cout << answer.size() << std::endl;
        for ( i = 0 ; i < answer.size() ; ++ i ) {
            std::cout << answer[i] << " ";
        }
    }

    return 0;
}


#include<cstdio>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<stack>
#include<queue>
#include<set>
#include<vector>
#include<map>
using namespace std;
#define MAXN 100000+1000
#define M 21
int sum,limit;
int me[MAXN],ans[MAXN];
int main()
{
    memset(me,0,sizeof(me));
    memset(ans,-1,sizeof(ans));
    cin>>sum>>limit;
    int i,d1,j=0,k;
    bool ok=false,ok1;
    for(i=0;i<M;i++)
    {
        if(((1<<i)&sum)==0) continue;
        d1=1<<i;
        ok=false;
        while(d1<=limit)
        {
            if(me[d1]!=1)
            {
                me[d1]=1;
                ans[j++]=d1;
                ok=true;
                break;
            }
            d1+=1<<(i+1);
        }
        if(!ok)
        {
            ok1=false;
            d1=1<<0;
            while(d1<=limit)
            {
                if(me[d1]!=1)
                {
                    me[d1]=1;
                    ans[j++]=d1;
                    ok1=true;
                    break;
                }
                d1+=1<<(1);
            }
            if(!ok1) break;
            for(k=0;k<i;k++)
            {
                d1=1<<k;
                ok1=false;
                while(d1<=limit)
                {
                    if(me[d1]!=1)
                    {
                        me[d1]=1;
                        ans[j++]=d1;
                        ok1=true;
                        break;
                    }
                    d1+=1<<(k+1);
                }
                if(!ok1) break;
            }
            if(!ok1) break;
            else ok=true;
        }
    }
//    for(i=0;i<j;i++)
//    {
//        printf("%d ",ans[i]);
//    }
//    cout<<endl;
    if(!ok) printf("-1\n");
    else
    {
        printf("%d\n",j);
        printf("%d",ans[0]);
        for(i=1;i<j;i++)
        {
            printf(" %d",ans[i]);
        }
        cout<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define MAXN 100000 + 1000
int sum,limit;
int ans[MAXN];
int me_ans;
bool ok;
struct Digit
{
    int pos;
    int dig;
    Digit()
    {
        pos=-1;
    }
}d[MAXN];
void build_pos()
{
    int i,j;
    for(i=0;i<=limit;i++)
    {
        d[i].dig=i;
        d[i].pos=-1;
        for(j=0;j<20;j++)
        {
            if(((1<<j)&i)!=0)
            {
                if(j<=sum) d[i].pos=(1<<j);
                break;
            }
        }
    }
}
bool comp(const Digit &a,const Digit &b)
{
    return a.pos<b.pos;
}
void dfs(int id,int much,int num)
{
//    printf("id=%d much=%d\n",id,much);
    if(much>sum) return;
    if(much==sum)
    {
        ok=true;
    }
    if(ok) return;
    int i;
    for(i=id;i<=limit;i++)
    {
        if(ok) break;
        ans[num]=i;
        dfs(i+1,much+d[i].pos,num+1);
        if(ok) break;
        ans[num]=-1;
    }
    return;
}
int main()
{
    memset(ans,-1,sizeof(ans));
    int id;
    me_ans=-1;
    cin>>sum>>limit;
    build_pos();
    if(me_ans!=-1)
    {
        printf("1\n");
        printf("%d\n",me_ans);
        return 0;
    }
    sort(d,d+limit+1,comp);
//    int i;
//    for(i=0;i<=limit;i++)
//    {
//        printf("pos=%d dig=%d\n",d[i].pos,d[i].dig);
//    }
    id=0;
    while(d[id].pos==-1)
    {
        id++;
    }
    ok=false;
    dfs(id,0,0);
    if(!ok) printf("-1\n");
    else
    {
        int k,i;
        for(i=0;;i++)
        {
            if(ans[i]==-1)
            {
                k=i;
                break;
            }
        }
        printf("%d\n",k);
        printf("%d",d[ans[0]].dig);
        for(i=1;i<k;i++)
        {
            printf(" %d",d[ans[i]].dig);
        }
        cout<<endl;
    }
    return 0;
}


#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define dep(i, a, b) for (int i = a; i > b; --i)
#define N 200005
using namespace std;

int init[N], cnt[N];
int n, m, ans;

int lowbit(int x)
{
    return x & -x;
}
bool find(int p)  {
    if (cnt[p])
    {
        cnt[p]--;
        ++ans;
        return 1;
    }
    if (p == 1) return 0;
    if (find(p >> 1) == 0) return 0;
    if (find(p >> 1) == 0) return 0;
    return 1;
}
int main()
{
    scanf("%d %d", &n, &m);
    rep(i, 0, m)
    {
        int val = lowbit(i+1);
        init[val]++;
        cnt[val]++;
    }
    for (int i = 20; i >= 0; --i)
        if ((n >> i) & 1)
        {
            if (find(1 << i) == 0)
            {
                printf("-1");
                exit(0);
            }
        }
    printf("%d\n", ans);
    rep(i, 0, m)
    {
        int val = lowbit(i+1);
        if (cnt[val] != init[val])
        {
            printf("%d ", i+1);
            cnt[val]++;
        }
    }
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <memory.h>
using namespace std;

int main()
{
	int s, m;
	scanf("%d %d", &s, &m);
	vector<int> ans;
	for (int i = m; i >= 1 && s; i--)
	{
		const int x = i & (-i);
		if (s >= x)
		{
			s -= x;
			ans.push_back(i);
		}
	}

	if (!s)
	{
		printf("%lu\n", ans.size());
		for (auto const& r : ans)
		{
			printf("%d ", r);
		}
	}
	else
	{
		puts("-1");
	}

	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <memory.h>
using namespace std;

pair<int,int> a[100007];

int main()
{
	int s, m;
	scanf("%d %d", &s, &m);
	for (int i = 1; i <= m; i++)
	{
		int k = 0;
		while (!(i & (1<<k)))
		{
			k++;
		}
		a[i].first = 1<<k;
		a[i].second = i;
	}

	vector<int> ans;
	sort(a+1, a+m+1, greater<pair<int,int>>());
	int k = m;
	while (k >= 1 && s)
	{
		if (a[k].first <= s)
		{
			ans.push_back(a[k].second);
			s -= a[k].first;
		}
		k--;
	}

	if (!s)
	{
		printf("%lu\n", ans.size());
		for (auto const& r : ans)
		{
			printf("%d ", r);
		}
	}
	else
	{
		puts("-1");
	}

	return 0;
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <fstream>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <limits>
#include <string.h>

 //#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

 int s, lm;
vector<int> t[40];

int main()
{

    cin>>s>>lm;

    int mx=-1;
    for (int i=1;i<=lm;i++){
        for (int j=0;j<=30;j++){
            if ( (i&(1<<j)) == 0){
                continue;
            }
            mx = max(mx , j);
            t[j].pb(i);
            break;
        }
    }
    int flag=0;
    int i=mx;
    vector<int> ans;
    while (s >= 0){
        if (i == -1){
            flag=1;
            break;
        }
        while (t[i].size() > 0 && s >= (1<<i) ){
            s-=(1<<i);
            ans.pb(t[i][0]);
            t[i].erase(t[i].begin()+0);
        }
        if (s == 0){
            break;
        }
        i--;
    }
    if (flag == 1){
        cout<<"-1\n";
    } else {
        cout<<ans.size()<<"\n";
        for (int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
    }
    return 0;
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <fstream>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <limits>
#include <string.h>

 //#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

 int s, lm;
vector<int> t[40];

int main()
{

    cin>>s>>lm;

    int mx=-1;
    for (int i=1;i<=lm;i++){
        for (int j=0;j<=30;j++){
            if ( (i&(1<<j)) == 0){
                continue;
            }
            mx = max(mx , j);
            t[j].pb(i);
            break;
        }
    }
    if(lm == 1) return 0;
    int flag=0;
    int i=mx;
    vector<int> ans;
    while (s >= 0){
        while (t[i].size() > 0 && s >= (1<<i) ){
            s-=(1<<i);
            ans.pb(t[i][0]);
            t[i].erase(t[i].begin()+0);
        }
        if (s == 0){
            break;
        }
        if (i == -1){
            flag=1;
            break;
        }
        i--;
    }
    if (flag == 1){
        cout<<"-1\n";
    } else {
        cout<<ans.size()<<"\n";
        for (int i=0;i<ans.size();i++){
            cout<<ans[i]<<" ";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define pn() printf("\n")
#define si(x) scanf("%d",&x)
#define pi(x) printf("%d\n",x)

#define sc(x) scanf("%c",&x)
#define pc(x) printf("%c",x)
#define sf(x) scanf("%f",&x)
#define pf(x) printf("%f\n",x)
#define sd(x) scanf("%lf",&x)
#define pd(x) printf("%.7lf\n",x)
#define sld(x) scanf("%Lf",&x)
#define pld(x) printf("%.9Lf\n",x)
#define MOD 100003
#define ll long long
using namespace std;
multiset<int> m;
multiset<int>::iterator it1,it2;
multiset<int>::reverse_iterator it3,it4;
int val[32][100000];
int idx[32];
int idx2[32];
int finalans[100001];
int dd=0;
int main(void){
    m.clear();
    int sum,limit;
    cin>>sum>>limit;
    ll mp=0;
    for(int i=1;i<=limit;i++){
        mp+=(i&(-i));
        int tt=(i&(-i));
        //cout<<i<<" "<<tt<<endl;
        //cout<<"inserting"<<tt<<endl;
        m.insert(tt);
        int bit=log2(tt);
        val[bit][idx[bit]++]=i;
    }
    if(mp<sum){
        cout<<"-1";
        return 0;
    }
    int needed=sum;
    for(it3=m.rbegin();it3!=m.rend()&&needed;it3++){
        if(*it3<=needed){
            needed-=*it3;
            finalans[dd]=val[(int)log2(*it3)][idx2[(int)log2(*it3)]];
            //cout<<needed<<" "<<*it1<<" "<<val[(int)log2(*it1)][idx2[(int)log2(*it1)]]<<endl;
            idx2[(int)log2(*it3)]++;
            dd++;
        }
    }
//    while(needed){
//        it1=m.lower_bound(needed);
//        cout<<"got"<<*it1<<endl;
//        needed-=*it1;
//        finalans[dd]=val[(int)log2(*it1)][idx2[(int)log2(*it1)]];
//        cout<<needed<<" "<<*it1<<" "<<val[(int)log2(*it1)][idx2[(int)log2(*it1)]]<<endl;
//        idx2[(int)log2(*it1)]++;
//        dd++;
//        m.erase(*it1);
//    }
    cout<<dd<<endl;
    for(int i=0;i<dd;i++){
        cout<<finalans[i]<<" ";
    }
    return 0;
}


#include <iostream>

using namespace std;

// Memory allocation for sets of lowmin 1's, 2's, 4's etc.
int set[100000], n = 0;

int genLows(int bit, int limit) {
    int low = 1 << bit, add = 1 << (bit+1), start = n;

    for(int i = 0; i + low <= limit; i+= add)
        set[n++] = i + low;

    return n - start;
}

int main() {
    int sum, limit, i, j, need, total = 0;
    int *lows[20], items[20], left[20];

    cin >> sum >> limit;

    for(i=0; i<20; i++) {
        lows[i] = set + n; // start
        left[i] = items[i] = genLows(i, limit);
    }

    for(i=0; i<20; i++) {
        if(!(sum & (1 << i)))
            continue; // skip the bit

        //cout << "Searching for " << (1 << i) << endl;

        for(need = (1 << i), j=i; need && j>=0; j--) {
            if(need > (left[j] << j)) { // not enough
                //cout << "Not enough (" << left[j] << ") " << (1<<j) << "'s for " << need << endl;
                need -= left[j] << j; // reduce need
                left[j] = 0; // all taken
            } else {
                //cout << "Taking some of " << (1<<j) << "'s for " << need << endl;
                left[j] -= need >> j; // take some
                need = 0; // done
            }
        }

        if(need) { // not enough
            cout << -1 << endl;
            return 0;
        }
    }

    for(i=0; i<20; i++)
        total += items[i] - left[i];

    cout << total << endl;

    for(i=0; i<20; i++) {
        for(j=0; j<items[i]-left[i]; j++) {
            cout << lows[i][j];
            if(--total > 0)
                cout << " ";
        }
    }

    cout << endl;

    return 0;
}


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

int lowBit(int x) {
    for(int i = 0 ; i < 25 ; ++i)
        if((x >> i) & 1)return (1 << i);
}

int main() {
    priority_queue<pair<int , vector<int> > > Q;
    int sum , limit;
    scanf("%d %d" , &sum , &limit);
    for(int i = 1 ; i <= limit ; ++i)
        Q.push(make_pair(-lowBit(i) , vector<int> (1 , i)));

    vector<int> ans;
    for(int i = 0 ; i < 35 ; ++i) {
        if((1 << i) > sum)break;

        if((sum >> i) & 1) {
            if(Q.size() == 0) {
                cout << -1 << endl;
                return 0;
            }
            pair<int , vector<int> > x = Q.top();
            Q.pop();
            if(-x.first != (1 << i)) {
                cout << -1 << endl;
                return 0;
            }
            for(auto &temp : x.second) {
                ans.push_back(temp);
            }
        }
        pair<int , vector<int> > a , b;
        while(1) {
            if(Q.size() == 0)break;
            a = Q.top();
            if(-a.first > (1 << i))break;
            Q.pop();
            if(Q.size() == 0)break;
            b = Q.top();
            if(-b.first > (1 << i))break;
            Q.pop();

            vector<int> temp;
            for(auto &x : a.second)
                temp.push_back(x);
            for(auto &x : b.second)
                temp.push_back(x);
            Q.push(make_pair(a.first + b.first , temp));
        }
    }
    int sz = ans.size();
    cout << sz << endl;
    for(auto &x : ans)
        cout << x << ' ' ;
    cout << endl;
    return 0;
}


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

int lowBit(int x) {
	return (x & -x);
}

int main() {
	priority_queue<pair<int , vector<int> > > Q;
	int sum , limit;
	scanf("%d %d" , &sum , &limit);

	vector<int> ans;
	for(int i = limit ; i >= 1 ; --i) {
		if(sum >= (i & -i)) {
			sum -= (i & -i);
			ans.push_back(i);
		}
	}
	if(sum) {
		printf("-1\n");
	}
	else {
		printf("%u\n" , ans.size());
		for(auto &x : ans)
			printf("%d " , x);
		printf("\n");
	}
	return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

#define PB push_back
#define MP make_pair
#define FF first
#define SS second

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(h);i>=(int)(l);--i)
#define FILL(x, val) memset(x, val, sizeof x)

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
#define ALL(X) X.begin(), X.end()
typedef pair <int,string> PIS;

const LL oo = 1e9+5;

#define SQ(X) (LL(X) * LL(X))
const LL mod = 1e9 + 7;
const int L = 1e5 + 5;

class gym {

public:
    void solve() {
        int sum, limit;
        cin >> sum >> limit;

        vector <PII> vals;
        FOR(i, 1, limit) {
            PII nv {0, i};
            REP(j, 20) {
                if ((1 << j) & i) {
                    nv.first = 1 << j;
                    break;
                }
            }

            vals.PB(nv);
        }

        sort(ALL(vals));
        VI ans;
        REP(i, vals.size()) {
            if (vals[i].first <= sum)
                ans.PB(vals[i].second), sum -= vals[i].first;
        }

        if (sum > 0)
            cout << -1 << endl;
        else {
            cout << ans.size() << endl;
            REP(i, ans.size())
                cout << ans[i] << " ";
            cout << endl;
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    gym obj;
    obj.solve();
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

#define PB push_back
#define MP make_pair
#define FF first
#define SS second

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(h);i>=(int)(l);--i)
#define FILL(x, val) memset(x, val, sizeof x)

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
#define ALL(X) X.begin(), X.end()
typedef pair <int,string> PIS;

const LL oo = 1e9+5;

#define SQ(X) (LL(X) * LL(X))
const LL mod = 1e9 + 7;
const int L = 1e5 + 5;

class gym {

public:
    void solve() {
        int sum, limit;
        cin >> sum >> limit;

        vector <PII> vals;
        FOR(i, 1, limit) {
            PII nv {0, i};
            REP(j, 20) {
                if ((1 << j) & i) {
                    nv.first = 1 << j;
                    break;
                }
            }

            vals.PB(nv);
        }

        reverse(ALL(vals));
        VI ans;
        REP(i, vals.size()) {
            if (vals[i].first <= sum)
                ans.PB(vals[i].second), sum -= vals[i].first;
        }

        if (sum > 0)
            cout << -1 << endl;
        else {
            cout << ans.size() << endl;
            REP(i, ans.size())
                cout << ans[i] << " ";
            cout << endl;
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    gym obj;
    obj.solve();
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <string.h>
#define MAX_N 3003
#define INF 1000000000
#define MOD 1000000007

using namespace std;

int sum, limit;

int main() {
	cin >> sum >> limit;
	vector<int> ans;
	for(int i = limit; i >= 1; i--) {
		int x = i, cnt = 0;
		while(x % 2 == 0) {
			x /= 2; cnt++;
		}
		if(sum >= (1 << cnt)) {
			ans.push_back(i);
			sum -= (1 << cnt);
		}
	}
	if(sum) cout << "-1" << endl;
	else {
		cout << ans.size() << endl;
		for(int i = 0; i < ans.size(); i++) {
			cout << ans[i] <<" ";
		}
	}
}


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

#define MX 100001
#define oo (1LL<<30)
#define SZ(x) ((int)x.size())
#define valid(x,u) (x>=0 && x<u)

int di [] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj [] = {1, -1, 0, 0, 1, -1, 1, -1};

int oss[18];

int lowBit(int num) {
    for(int i=0; i<18; ++i) {
        if(num & (1 << i)) {
            return i+1;
        }
    }
    return 18;
}

bool cmp(int a, int b) {
    return lowBit(a) < lowBit(b);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int goal, lim; cin >> goal >> lim;

    vector <int> vec(lim), ans;
    for(int i=1; i<=lim; ++i) {
        vec[i-1] = i;
    }
    sort(vec.rbegin(), vec.rend(), cmp);

    for(int i=0; i<SZ(vec); ++i) {
        if(lowBit(vec[i]) > goal) continue;
        goal -= lowBit(vec[i]);
        ans.push_back(vec[i]);
    }

    if(goal) {
        cout << -1 << '\n';
        return 0;
    }

    cout << SZ(ans) << '\n';
    for(int i=0; i<SZ(ans); ++i) {
        cout << ans[i] << " ";
    }

    return 0;
}


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

#define MX 100001
#define oo (1LL<<30)
#define SZ(x) ((int)x.size())
#define valid(x,u) (x>=0 && x<u)

int di [] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj [] = {1, -1, 0, 0, 1, -1, 1, -1};

int oss[18];

int lowBit(int num) {
    for(int i=0; i<18; ++i) {
        if(num & (1 << i)) {
            return (1<<i);
        }
    }
    return 18;
}

bool cmp(int a, int b) {
    return lowBit(a) < lowBit(b);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int goal, lim; cin >> goal >> lim;

    vector <int> vec(lim), ans;
    for(int i=1; i<=lim; ++i) {
        vec[i-1] = i;
    }
    sort(vec.rbegin(), vec.rend(), cmp);

    for(int i=0; i<SZ(vec); ++i) {
        if(lowBit(vec[i]) > goal) continue;
        goal -= lowBit(vec[i]);
        ans.push_back(vec[i]);
    }

    if(goal) {
        cout << -1 << '\n';
        return 0;
    }

    sort(ans.begin(), ans.end());
    cout << SZ(ans) << '\n';
    for(int i=0; i<SZ(ans); ++i) {
        cout << ans[i] << " ";
    }

    return 0;
}


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

#define SZ(x) ((int)(x).size())

bool cmp(int a, int b) {
    return (a&-a) < (b&-b);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    int sum, lim;
    cin >> sum >> lim;
    vector<int> vec;
    for (int i = 1; i <= lim; ++i) {
        vec.push_back(i);
    }
    sort(vec.rbegin(), vec.rend());
    vector<int> ans;
    for (int i = 0; i < SZ(vec); ++i) {
        int lb = vec[i]&-vec[i];
        if (lb <= sum) {
            sum -= lb;
            ans.push_back(vec[i]);
        }
    }

    if (sum == 0) {
        cout << SZ(ans) << '\n';
        for (int i = 0; i < SZ(ans); ++i) {
            cout << ans[i] << " \n"[i == SZ(ans) - 1];
        }
    } else {
        cout << -1 << '\n';
    }

    return 0;
}


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

#define SZ(x) ((int)(x).size())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    int sum, lim;
    cin >> sum >> lim;
    vector<int> vec;
    for (int i = lim; i >= 1; --i) {
        vec.push_back(i);
    }
    vector<int> ans;
    for (int i = 0; i < SZ(vec); ++i) {
        int lb = (vec[i]&-vec[i]);
        if (lb <= sum) {
            sum -= lb;
            ans.push_back(vec[i]);
        }
    }
    if (sum != 0) cout << -1 << '\n';
    else {
        cout << SZ(ans) << '\n';
        for (int i = 0; i < SZ(ans); ++i) {
            cout << ans[i] << " \n"[i == SZ(ans) - 1];
        }
    }
    return 0;
}


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

#define MX 100001
#define oo (1LL<<30)
#define SZ(x) ((int)x.size())
#define valid(x,u) (x>=0 && x<u)

int di [] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj [] = {1, -1, 0, 0, 1, -1, 1, -1};

int oss[18];

int lowBit(int num) {
    for(int i=0; i<18; ++i) {
        if(num & (1 << i)) {
            return i+1;
        }
    }
    return 18;
}

bool cmp(int a, int b) {
    return lowBit(a) < lowBit(b);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int goal, lim; cin >> goal >> lim;

    vector <int> vec(lim), ans;
    for(int i=1; i<=lim; ++i) {
        vec[i-1] = i;
    }
    sort(vec.rbegin(), vec.rend(), cmp);

    for(int i=0; i<SZ(vec); ++i) {
        if(lowBit(vec[i]) > goal) continue;
        goal -= lowBit(vec[i]);
        ans.push_back(vec[i]);
    }

    if(goal) {
        cout << -1 << '\n';
        return 0;
    }

    sort(ans.begin(), ans.end());
    cout << SZ(ans) << '\n';
    for(int i=0; i<SZ(ans); ++i) {
        cout << ans[i] << " ";
    }

    return 0;
}


#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <numeric>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <limits.h>

using namespace std;

typedef long long ll;

#define mem(a,b) memset(a,b, sizeof a)
#define SZ(x)	(int)x.size()
#define FOREACH(it,x) for(__typeof((x).begin()) it=(x.begin());it!=(x.end());++it)
#define ERR 1e-5
#define PI (2.0*acos(0))
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define rep(i,n,m) for(int i = (int)n,_m=(int)m;i<_m;++i)
#define bj(stat,b) (stat & (1<<b))
#define bc(stat,b) (stat & (~(1<<b)))
#define vi vector<int>
#define vs vector<string>

#define popc(i) (__builtin_popcountll(i))
// i should not be zero
#define low_bit_index(i) (__builtin_ctz(i))
#define high_bit_index(i) (sizeof(i)*8-1-__builtin_clz(i))
#define last_bit(i) (i&~(i-1))

template <class T> T Abs(T x) {return x<0?-x:x;}

#define MAXN 100000
int a[MAXN+10];
int seq[MAXN+10];
bool cmp(int x, int y) {
	return a[x]<a[y];
}

int
main()
{
	int M,N;

	while(cin>>M>>N) {
		//mem (a,-1);
		rep(i,1,N+1) {a[i]=last_bit(i);seq[i]=i;}

		sort(seq+1,seq+1+N,cmp);
		vi ans;

		for(int i=N;i>0;i--) {
			if(M>=a[seq[i]]) {
				M-=a[seq[i]];
				ans.pb(i);
			}
		}

		if(M) cout<<-1<<endl;
		else {
			cout<<SZ(ans)<<endl;
			cout<<ans[0];
			rep(i,1,SZ(ans)) cout<<" "<<ans[i];
			cout<<endl;
		}
	}
}


#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <numeric>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <limits.h>

using namespace std;

typedef long long ll;

#define mem(a,b) memset(a,b, sizeof a)
#define SZ(x)	(int)x.size()
#define FOREACH(it,x) for(__typeof((x).begin()) it=(x.begin());it!=(x.end());++it)
#define ERR 1e-5
#define PI (2.0*acos(0))
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define rep(i,n,m) for(int i = (int)n,_m=(int)m;i<_m;++i)
#define bj(stat,b) (stat & (1<<b))
#define bc(stat,b) (stat & (~(1<<b)))
#define vi vector<int>
#define vs vector<string>

#define popc(i) (__builtin_popcountll(i))
// i should not be zero
#define low_bit_index(i) (__builtin_ctz(i))
#define high_bit_index(i) (sizeof(i)*8-1-__builtin_clz(i))
#define last_bit(i) (i&~(i-1))

template <class T> T Abs(T x) {return x<0?-x:x;}

#define MAXN 100000
int a[MAXN+10];
int seq[MAXN+10];
bool cmp(int x, int y) {
	return a[x]<a[y];
}

int
main()
{
	int M,N;

	while(cin>>M>>N) {
		//mem (a,-1);
		rep(i,1,N+1) {a[i]=last_bit(i);seq[i]=i;}

		sort(seq+1,seq+1+N,cmp);
		vi ans;

		for(int i=N;i>0;i--) {
			if(M>=a[seq[i]]) {
				M-=a[seq[i]];
				ans.pb(seq[i]);
			}
		}

		if(M) cout<<-1<<endl;
		else {
			cout<<SZ(ans)<<endl;
			cout<<ans[0];
			rep(i,1,SZ(ans)) cout<<" "<<ans[i];
			cout<<endl;
		}
	}
}


#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <numeric>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <limits.h>

using namespace std;

typedef long long ll;

#define mem(a,b) memset(a,b, sizeof a)
#define SZ(x)	(int)x.size()
#define FOREACH(it,x) for(__typeof((x).begin()) it=(x.begin());it!=(x.end());++it)
#define ERR 1e-5
#define PI (2.0*acos(0))
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define rep(i,n,m) for(int i = (int)n,_m=(int)m;i<_m;++i)
#define bj(stat,b) (stat & (1<<b))
#define bc(stat,b) (stat & (~(1<<b)))
#define vi vector<int>
#define vs vector<string>

#define popc(i) (__builtin_popcountll(i))
// i should not be zero
#define low_bit_index(i) (__builtin_ctz(i))
#define high_bit_index(i) (sizeof(i)*8-1-__builtin_clz(i))
#define last_bit(i) (i&~(i-1))

template <class T> T Abs(T x) {return x<0?-x:x;}

#define MAXN 100000
int a[MAXN+10];
int
main()
{
	int M,N;

	while(cin>>M>>N) {
		//mem (a,-1);
		//rep(i,1,N+1) a[last_bit(i)]=i;
		vi ans;

		rep(i,1,N+1) {
			if(M>=last_bit(i)) {
				M-=last_bit(i);
				ans.pb(i);
			}
		}

		if(M) cout<<-1<<endl;
		else {
			cout<<SZ(ans)<<endl;
			cout<<ans[0];
			rep(i,1,SZ(ans)) cout<<" "<<ans[i];
			cout<<endl;
		}
	}
}


#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <numeric>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <limits.h>

using namespace std;

typedef long long ll;

#define mem(a,b) memset(a,b, sizeof a)
#define SZ(x)	(int)x.size()
#define FOREACH(it,x) for(__typeof((x).begin()) it=(x.begin());it!=(x.end());++it)
#define ERR 1e-5
#define PI (2.0*acos(0))
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define rep(i,n,m) for(int i = (int)n,_m=(int)m;i<_m;++i)
#define bj(stat,b) (stat & (1<<b))
#define bc(stat,b) (stat & (~(1<<b)))
#define vi vector<int>
#define vs vector<string>

#define popc(i) (__builtin_popcountll(i))
// i should not be zero
#define low_bit_index(i) (__builtin_ctz(i))
#define high_bit_index(i) (sizeof(i)*8-1-__builtin_clz(i))
#define last_bit(i) (i&~(i-1))

template <class T> T Abs(T x) {return x<0?-x:x;}

#define MAXN 100000
int a[MAXN+1];
bool dp[MAXN+1][MAXN+1];
//bool b[MAXN+1][MAXN+1];
int
main()
{
	int M,N;

	while(cin>>M>>N) {

		rep(i,1,N+1) a[i]=last_bit(i);
	//	rep(i,1,N+1) cout<<a[i]<<endl;
		mem (dp,false);

		//int kk=0;
		dp[0][0]=true;

		vi ans;
		//kk=1-kk;
		rep(i,1,N+1) {
			rep(j,0,M+1) {
			if(dp[i-1][j]) dp[i][j]=true;
			else if(j>=a[i] && dp[i-1][j-a[i]]) {
				dp[i][j]=true;
				//ans.pb(i);
			}
			//kk=1-kk;
			//printf("%d %d %d\n",i,j,dp[1-kk][j]);
			}
		}

		//kk=1-kk;

		int i=N;
		int j=M;

		for(;i>0 && dp[i][j];i--) {
			if(j>=a[i] && dp[i-1][j-a[i]]) {
				ans.pb(i);
				j -= a[i];
			}
		}
		if(SZ(ans)==0) cout<<-1<<endl;
		else {
			cout<<SZ(ans)<<endl;
			cout<<ans[0];
			rep(i,1,SZ(ans)) cout<<" "<<ans[i];
			cout<<endl;
		}
	}
}


#include <bits/stdtr1c++.h>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<ld> pt;

int cnt[1000];
vector<int> num[100];
int main() {
    ll sum, lim;
    cin >> sum >> lim;

    memset(cnt, 0, sizeof cnt);
    for (int i = 1; i <= lim; i++) {
        cnt[__builtin_ctz(i)]++;
        num[__builtin_ctz(i)].push_back(i);
    }

    vector<ll> S;
    for (int i = 0; (1LL << i) <= sum; i++) {
        ll bit = (1LL << i);
        if (!(bit&sum)) continue;

        if (cnt[i]) {
            S.push_back(num[i].back());
            cnt[i]--;
            num[i].pop_back();
        } else {
            int j = i-1;
            ll s = 0;

            while (s != bit && j >= 0) {
                while (!num[j].empty()) {
                    S.push_back(num[j].back());
                    num[j].pop_back();
                    cnt[j]--;
                    s += (1 << j);
                    if (s == bit) break;
                }
                if (s == bit) break;
                j--;
            }

            if (j < 0) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    sort(S.begin(), S.end());
    //int s = 0;
    cout << S.size() << endl;
    for (int i = 0; i < S.size(); i++) {
        cout << S[i] << " ";
        //s += (1 << __builtin_ctz(S[i]));
    }
    cout << endl;
    //cout << s << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

#define MAX 100001

int lbit[MAX];

bool large(int a, int b)
{
    return lbit[a] > lbit[b];
}

int lowbit(int a)
{
    int b = 1;
    while (!(a&1))
        a >>= 1, b <<= 1;
    return b;
}

int main()
{
    int sum, limit;
    cin >> sum >> limit;

    int id[MAX];
    for (int i=1; i<=limit; i++)
    {
        lbit[i] = lowbit(i);
        id[i-1] = i;
    }

    sort(id, id+limit, large);

    vector<int> v;
    for (int i=0; i<limit; i++)
    {
        if (lbit[id[i]] <= sum)
        {
            sum -= lbit[id[i]];
            v.push_back(id[i]);
        }
    }

    if (sum)
        cout << "-1" << endl;
    else
    {
        cout << v.size() << endl;
        for (int i=0; i<v.size(); i++)
            cout << ( i ? " " : "" ) << v[i];
        cout << endl;
    }

    return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 100005;
int s,m;
int num[maxn];
int lowbit(int x)
{
    return x&(-x);
}
int main()
{
    int i,j;
    while(scanf("%d%d",&s,&m)!=EOF)
    {
        int k=0;
        for(i=m;i>=1;i--)
        {
            if(lowbit(i)<=s)
            {
                num[k++]=i;
                s-=lowbit(i);
            }
        }
        if(s==0)
        {
            printf("%d\n",k);
            for(i=0;i<k;i++)
            {
                if(i==0)
                printf("%d",num[i]);
                else
                    printf(" %d",num[i]);
            }
            printf("\n");
        }
        else
            printf("-1\n");
    }
    return 0;

}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 100005;
int s,m;
int num[maxn];
int lowbit(int x)
{
    return x&(-x);
}
int main()
{
    int i,j;
    while(scanf("%d%d",&s,&m)!=EOF)
    {
        int k=0;
        for(i=1;i<=m;i++)
        {
            if(lowbit(i)<=s)
            {
                num[k++]=i;
                s-=lowbit(i);
            }
        }
        if(s==0)
        {
            printf("%d\n",k);
            for(i=0;i<k;i++)
            {
                if(i==0)
                printf("%d",num[i]);
                else
                    printf(" %d",num[i]);
            }
            printf("\n");
        }
        else
            printf("-1\n");
    }
    return 0;

}


#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <complex>
#include <sstream>
#include <utility>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>

#define OO (int) 1e9

using namespace std;

int gcd(int u, int v) {return (v != 0)?gcd(v, u%v):u;}

int main()
{
    ios_base::sync_with_stdio(false);

    int sum,limit;
    cin>>sum>>limit;
    vector <int> res;
    for(int i=1;i<=limit;i++)
    {
        if( (i&-i) <=sum )
        {
            sum-=(i&-i);
            res.push_back(i);
        }
        else if (sum-(i&-i)==1)
        {
            sum=0;
            res.erase(res.begin());
            res.push_back(i);
        }
        if(!sum) break;
    }
    if(sum)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<res.size()<<endl;
    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";

}


#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <complex>
#include <sstream>
#include <utility>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>

#define OO (int) 1e9

using namespace std;

int gcd(int u, int v) {return (v != 0)?gcd(v, u%v):u;}

int main()
{
    ios_base::sync_with_stdio(false);

    int sum,limit;
    cin>>sum>>limit;
    vector <int> res;
    for(int i=limit;i>=1;i--)
    {
        if( (i&-i) <=sum )
        {
            sum-=(i&-i);
            res.push_back(i);
        }
        if(!sum) break;
    }
    if(sum)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<res.size()<<endl;
    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";

}


#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <complex>
#include <sstream>
#include <utility>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>

#define OO (int) 1e9

using namespace std;

int gcd(int u, int v) {return (v != 0)?gcd(v, u%v):u;}

int main()
{
    ios_base::sync_with_stdio(false);

    int sum,limit;
    cin>>sum>>limit;
    vector <int> res;
    while(sum)
    {
        res.push_back((sum&-sum));
        sum-=(sum&-sum);
    }
    int Max=*max_element(res.begin(),res.end());
    if(Max>limit) {
        cout<<-1<<endl;
        return 0;
    }
    cout<<res.size()<<endl;
    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";

}


#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <complex>
#include <sstream>
#include <utility>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>

#define OO (int) 1e9

using namespace std;

int gcd(int u, int v) {return (v != 0)?gcd(v, u%v):u;}

int main()
{
    ios_base::sync_with_stdio(false);

    int sum,limit;
    cin>>sum>>limit;
    vector <int> res;
    for(int i=1;i<=limit;i++)
    {
        if( (i&-i) <=sum )
        {
            sum-=(i&-i);
            res.push_back(i);
        }
        else if (sum-(i&-i)==1)
        {
            sum=0;
            res.erase(res.begin());
        }
    }
    if(sum)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<res.size()<<endl;
    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";

}


#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <complex>
#include <sstream>
#include <utility>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>

#define OO (int) 1e9

using namespace std;

int gcd(int u, int v) {return (v != 0)?gcd(v, u%v):u;}

int main()
{
    ios_base::sync_with_stdio(false);

    int sum,limit;
    cin>>sum>>limit;
    vector <int> res;
    for(int i=1;i<=limit;i++)
    {
        if( (i&-i) <=sum )
        {
            sum-=(i&-i);
            res.push_back(i);
        }
        else if ((i&-i)-sum==1)
        {
            sum=0;
            res.erase(res.begin());
            res.push_back(i);
        }
        if(!sum) break;
    }
    if(sum)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<res.size()<<endl;
    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";

}


#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <complex>
#include <sstream>
#include <utility>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>

#define OO (int) 1e9

using namespace std;

int gcd(int u, int v) {return (v != 0)?gcd(v, u%v):u;}

int main()
{
    ios_base::sync_with_stdio(false);

    int sum,limit;
    cin>>sum>>limit;
    vector <int> res;
    while(sum)
    {
        res.push_back((sum&-sum));
        sum-=(sum&-sum);
    }
    int Max=*max_element(res.begin(),res.end());
    if(Max>limit) {
        cout<<-1<<endl;
        return 0;
    }
    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";

}


#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <complex>
#include <sstream>
#include <utility>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>

#define OO (int) 1e9

using namespace std;

int gcd(int u, int v) {return (v != 0)?gcd(v, u%v):u;}

int main()
{
    ios_base::sync_with_stdio(false);

    int sum,limit;
    cin>>sum>>limit;
    vector <int> res;
    for(int i=1;i<=limit;i++)
    {
        if( (i&-i) <=sum )
        {
            sum-=(i&-i);
            res.push_back(i);
        }
    }
    if(sum)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<res.size()<<endl;
    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";

}


#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <complex>
#include <sstream>
#include <utility>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>

#define OO (int) 1e9

using namespace std;

int gcd(int u, int v) {return (v != 0)?gcd(v, u%v):u;}

int main()
{
    ios_base::sync_with_stdio(false);

    int sum,limit;
    cin>>sum>>limit;
    vector <int> res;
    for(int i=1;i<=limit;i++)
    {
        if( (i&-i) <=sum )
        {
            sum-=(i&-i);
            res.push_back(i);
        }
        else if (sum-(i&-i)==1)
        {
            sum=0;
            res.erase(res.begin());
        }
        if(!sum) break;
    }
    if(sum)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<res.size()<<endl;
    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";

}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <queue>
#include <algorithm>
#define mem(f) memset(f,0,sizeof(f))
#define M 100005
#define mod 1000000007
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
using namespace std;
typedef __int64 LL;
const int MAX = 0x3f3f3f3f;
const int maxn = 2111111;

int tot, n, tmp,ans[12345];
struct C {
    int num, bit;
} a[12345];

bool cmp(C x, C y) {
    return x.bit > y.bit;
}

int main()
{
    cin >> tot >> n;
    for(int i = 0; i < n; i++) {
        tmp = i+1;
        a[i].bit = tmp&-tmp;
        a[i].num = i+1;
    }
    sort(a, a+n, cmp);
    int k = 0;
    for(int i = 0; i < n; i++) {
        if(tot - a[i].bit < 0) continue;
        tot -= a[i].bit;
        ans[k++] = a[i].num;
        if(tot == 0) break;
    }
    if(tot == 0) {
        printf("%d\n", k);
        for(int i = k-1; i >= 0; i--) printf("%d ", ans[i]);
    }  else printf("-1");
    puts("");
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <queue>
#include <algorithm>
#define mem(f) memset(f,0,sizeof(f))
#define M 100005
#define mod 1000000007
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
using namespace std;
typedef __int64 LL;
const int MAX = 0x3f3f3f3f;
const int maxn = 2111111;

int tot, n, tmp,ans[123456];
struct C {
    int num, bit;
} a[123456];

bool cmp(C x, C y) {
    return x.bit < y.bit;
}

int main()
{
    cin >> tot >> n;
    for(int i = 0; i < n; i++) {
        tmp = i+1;
        a[i].bit = tmp&-tmp;
        a[i].num = i+1;
    }
    sort(a, a+n, cmp);
    //for(int i = 0; i < n; i++) cout << a[i].bit << " ";
    int k = 0;
    for(int i = 0; i < n; i++) {
        if(tot - a[i].bit < 0) continue;
        tot -= a[i].bit;
        ans[k++] = a[i].num;
        if(tot == 0) break;
    }
    if(tot == 0) {
        printf("%d\n", k);
        for(int i = k-1; i >= 0; i--) printf("%d ", ans[i]);
    }  else printf("-1");
    puts("");
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <queue>
#include <algorithm>
#define mem(f) memset(f,0,sizeof(f))
#define M 100005
#define mod 1000000007
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
using namespace std;
typedef __int64 LL;
const int MAX = 0x3f3f3f3f;
const int maxn = 2111111;

int tot, n, tmp,ans[123456];
struct C {
    int num, bit;
} a[123456];

bool cmp(C x, C y) {
    return x.bit > y.bit;
}

int main()
{
    cin >> tot >> n;
    for(int i = 0; i < n; i++) {
        tmp = i+1;
        a[i].bit = tmp&-tmp;
        a[i].num = i+1;
    }
    sort(a, a+n, cmp);
    int k = 0;
    for(int i = 0; i < n; i++) {
        if(tot - a[i].bit < 0) continue;
        tot -= a[i].bit;
        ans[k++] = a[i].num;
        if(tot == 0) break;
    }
    if(tot == 0) {
        printf("%d\n", k);
        for(int i = k-1; i >= 0; i--) printf("%d ", ans[i]);
    }  else printf("-1");
    puts("");
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <queue>
#include <algorithm>
#define mem(f) memset(f,0,sizeof(f))
#define M 100005
#define mod 1000000007
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
using namespace std;
typedef __int64 LL;
const int MAX = 0x3f3f3f3f;
const int maxn = 2111111;

int tot, n, tmp,ans[123456];
struct C {
    int num, bit;
} a[123456];

bool cmp(C x, C y) {
    return x.bit > y.bit;
}

int main()
{
    cin >> tot >> n;
    for(int i = 0; i < n; i++) {
        tmp = i+1;
        a[i].bit = tmp&-tmp;
        a[i].num = i+1;
    }
    sort(a, a+n, cmp);
    //for(int i = 0; i < n; i++) cout << a[i].bit << " ";
    int k = 0;
    for(int i = 0; i < n; i++) {
        if(tot - a[i].bit < 0) continue;
        tot -= a[i].bit;
        ans[k++] = a[i].num;
        if(tot == 0) break;
    }
    if(tot == 0) {
        printf("%d\n", k);
        for(int i = k-1; i >= 0; i--) printf("%d ", ans[i]);
    }  else printf("-1");
    puts("");
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <queue>
#include <algorithm>
#define mem(f) memset(f,0,sizeof(f))
#define M 100005
#define mod 1000000007
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
using namespace std;
typedef __int64 LL;
const int MAX = 0x3f3f3f3f;
const int maxn = 2111111;

int tot, n, tmp,ans[12345];
struct C {
    int num, bit;
} a[12345];

bool cmp(C x, C y) {
    return x.bit > y.bit;
}

int main()
{
    cin >> tot >> n;
    for(int i = 0; i < n; i++) {
        tmp = i+1;
        a[i].bit = tmp&-tmp;
        a[i].num = i+1;
    }
    sort(a, a+n, cmp);
    int k = 0;
    for(int i = 0; i < n; i++) {
        if(tot - a[i].bit < 0) continue;
        tot -= a[i].bit;
        ans[k++] = a[i].num;
        if(tot == 0) break;
    }
    if(tot == 0) for(int i = k-1; i >= 0; i--) printf("%d ", ans[i]);
    else printf("-1");
    puts("");
    return 0;
}


//#include <bits/stdc++.h>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <vector>
#include <bitset>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>
#include <iostream>
#include <algorithm>

using namespace std;

#define sf              scanf
#define pf              printf
#define fs              first
#define se              second
#define pb              push_back
#define ins             insert
#define Lb              lower_bound
#define Up              upper_bound
#define INF             0x7F7F7F7F
#define mem(a,b)        memset(a, b, sizeof(a))
#define MAX             100010
#define MAXR            100010
#define MAXC            100010

typedef long long ll;

const double PI = 2.0 * acos(0.0);
const double eps = 1e-9;

template < class T > T Abs(T x) { return x > 0 ? x : -x; }
template < class T > string toString(T n) { ostringstream ost; ost << n; ost.flush() ; return ost.str(); }
template < class T > inline T sqr(T n) { return n * n; }

template < class T > inline T gcd(T a,T b)
{
    if(a < 0) return gcd(-a,b);
    if(b < 0) return gcd(a,-b);
    return (b == 0) ? a : gcd(b ,a % b);
}

template < class T > inline T lcm(T a,T b)
{
    if(a < 0) return lcm(-a,b);
    if(b < 0) return lcm(a,-b);
    return a * (b / gcd(a , b));
}

template < class T > T power(T n, int p)
{
    if(!p) return 1;
    else
    {
        T sum = sqr( power( n ,  p >> 1) );
        if(p & 1) sum =  n;
        return sum;
    }
}

//ll bigmod(ll num , ll p , ll mod)
//{
//    ll sum = 1 , temp = num;
//    while(p)
//    {
//        if(p & 1) sum = (sum * temp) % mod;
//        temp = (temp * temp) % mod; p = p >> 1;
//    }
//    return sum;
//}

/// S , E  , N , W
////int one [] = {0 ,1 , 0,-1};
////int two [] = {1 ,0 ,-1, 0};
///S , SE , E , NE , N , NW , W , SW
//int one [] = {1 ,1 ,0,-1,-1,-1, 0, 1};
//int two [] = {0 ,1 ,1 ,1, 0,-1,-1,-1};
///Knight Direction
//int one[]={2 ,1 ,-1,-2,-2,-1, 1, 2};
//int two[]={1 ,2 , 2, 1,-1,-2,-2,-1};

///***********************************************END*********************************//////////////////

vector < int > ve;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(false);
    int n , p , sum = 0;
    cin >> n >> p;
    for(int i = p ; i >= 1 ; --i)
    {
        if(sum + (i & -i) <= n)
        {
            sum = sum + (i & -i);
            ve.pb(i);
        }
    }
    if(sum != n)
    {
        cout << "-1" << endl;
        return 0;
    }
    cout <<  (int) ve.size() << endl;
    for(int i = 0 ; i < (int) ve.size() ; ++i) cout << ve[i] << " ";
    return 0;
}