#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
const int debug=0;
using namespace std;
const int MAXN = 200020;
const int INF=0x3f3f3f3f;
bool use[200020]={0};
map<int,vector<int> > mp;
vector<int> fmp;
vector<int> con[130];
#define PB(X) push_back(X)
#define MP(X,Y) make_pair(X,Y)
typedef pair<int,int> PII ;
typedef vector<PII> VII ;

#define INF 0x3FFFFFFF
vector<int> G[MAXN];
void add_edge(int u,int v)
{
    G[u].PB(v);
}
void init(int n){
    for(int i=0;i<n;i++)
		G[i].clear();
}
int vis[MAXN];
int dis[MAXN];
int pre[MAXN];
void spfa(int s,int n)
{
    for(int i = 0;i<n;i++)
		dis[i] = (i == s ? 0 : INF);
    memset(vis,0,sizeof(vis));
	pre[s]=s;
    queue<int>q;
    q.push(s);
    while(!q.empty())
	{
        int x = q.front();
        q.pop();
        vis[x] = 0;
        for(int i = 0;i<G[x].size();i++)
		{
            int y = G[x][i];
            int d =-mp[fmp[x]].size();
            if(dis[y] > dis[x] + d)
			{
                dis[y] = dis[x] + d;
				pre[y]=x;
                if(!vis[y])
				{
                    q.push(y);
                    vis[y] = 1;
                }
            }
        }
    }
}

int gcd(int a,int b)
{
	return (b==0)?a:gcd(b, a%b);
}

void extgcd(int a,int b,int &d,int &x,int &y)//扩展欧几里得
{

	if(!b)
	{
		d=a;x=1;y=0;
	}
	else
	{
		extgcd(b,a%b,d,y,x);
		y-=x*(a/b);
	}
}

bool modsolve(int a,int b,int m,int &x)
{
	int d,x0,y0;
	extgcd(a,m,d,x0,y0);
	if (b%d==0)
	{
		x=x0*b/d;
		return true;
	}
	return false;
}

vector<int> ans;
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		use[a]=true;
	}
	mp[0].push_back(0);
	fmp.push_back(0);
	for(int i=1;i<m;i++)
		if(!use[i])
		{
			int g=gcd(i,m);
			mp[g].push_back(i);
			if(mp[g].size()==1)
				fmp.push_back(g);
		}
	if (debug)
	{
		cout<<mp.size()<<endl;
		for(map<int,vector<int> >::iterator it=mp.begin();it!=mp.end();it++)
		{
			cout<<it->first<<"   "<<it->second.size()<<endl;
		}
	}
	n=fmp.size();
	mp[m].clear();
	fmp.push_back(m);
	init(n+1);
	add_edge(n,0);
	for(int i=1;i<n;i++)
	{
		add_edge(n,i);
		add_edge(i,0);
		for(int j=i+1;j<n;j++)
			if(fmp[j]%fmp[i]==0)
				add_edge(i,j);
	}
	spfa(n,n+1);
	int now=0;
	if(use[0])
	{
		cout<<-dis[0]<<endl;
		now=pre[now];
	}
	else
		cout<<1-dis[0]<<endl;
	while(pre[now]!=now)
	{
		if (debug)
			cout<<now<<"  "<<fmp[now]<<"  "<<mp[fmp[now]].size()<<endl;
		for(int i=0;i<mp[fmp[now]].size();i++)
			ans.push_back(mp[fmp[now]][i]);
		now=pre[now];
	}
	if (debug)
	{
		cout<<ans.size()<<endl;
		for(int i=ans.size()-1;i>=0;i--)
			cout<<ans[i]<<' ';
		cout<<endl;
	}
	int pj=1;
	for(int i=ans.size()-1;i>=0;i--)
	{
		int tmp;
		modsolve(pj,ans[i],m,tmp);
		while(tmp<0)
			tmp+=m;
		tmp=tmp%m;
		pj=(pj*tmp)%m;
		if(use[pj])
		{
			cout<<"wa\n";
			break;
		}
		else
			use[pj]=true;
		if (debug)
			printf("%d:%d ",tmp,pj);
		else if(i)
			printf("%d ",tmp);
		else
			printf("%d\n",tmp);
	}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
const int debug=0;
using namespace std;
const int MAXN = 200020;
const int INF=0x3f3f3f3f;
bool use[200020]={0};
map<int,vector<int> > mp;
vector<int> fmp;
vector<int> con[130];
#define PB(X) push_back(X)
#define MP(X,Y) make_pair(X,Y)
typedef pair<int,int> PII ;
typedef vector<PII> VII ;

#define INF 0x3FFFFFFF
vector<int> G[MAXN];
void add_edge(int u,int v)
{
    G[u].PB(v);
}
void init(int n){
    for(int i=0;i<n;i++)
		G[i].clear();
}
int vis[MAXN];
int dis[MAXN];
int pre[MAXN];
void spfa(int s,int n)
{
    for(int i = 0;i<n;i++)
		dis[i] = (i == s ? 0 : INF);
    memset(vis,0,sizeof(vis));
	pre[s]=s;
    queue<int>q;
    q.push(s);
    while(!q.empty())
	{
        int x = q.front();
        q.pop();
        vis[x] = 0;
        for(int i = 0;i<G[x].size();i++)
		{
            int y = G[x][i];
            int d =-mp[fmp[x]].size();
            if(dis[y] > dis[x] + d)
			{
                dis[y] = dis[x] + d;
				pre[y]=x;
                if(!vis[y])
				{
                    q.push(y);
                    vis[y] = 1;
                }
            }
        }
    }
}

int gcd(int a,int b)
{
	return (b==0)?a:gcd(b, a%b);
}

void extgcd(long long a,long long b,long long &d,long long &x,long long &y)//扩展欧几里得
{

	if(!b)
	{
		d=a;x=1;y=0;
	}
	else
	{
		extgcd(b,a%b,d,y,x);
		y-=x*(a/b);
	}
}

bool modsolve(long long a,long long b,long long m,long long &x)
{
	long long d,x0,y0;
	extgcd(a,m,d,x0,y0);
	if (b%d==0)
	{
		x=x0*b/d;
		return true;
	}
	return false;
}

vector<int> ans;
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		use[a]=true;
	}
	mp[0].push_back(0);
	fmp.push_back(0);
	for(int i=1;i<m;i++)
		if(!use[i])
		{
			int g=gcd(i,m);
			mp[g].push_back(i);
			if(mp[g].size()==1)
				fmp.push_back(g);
		}
	if (debug)
	{
		cout<<mp.size()<<endl;
		for(map<int,vector<int> >::iterator it=mp.begin();it!=mp.end();it++)
		{
			cout<<it->first<<"   "<<it->second.size()<<endl;
		}
	}
	n=fmp.size();
	mp[m].clear();
	fmp.push_back(m);
	init(n+1);
	add_edge(n,0);
	for(int i=1;i<n;i++)
	{
		add_edge(n,i);
		add_edge(i,0);
		for(int j=1;j<n;j++)
			if(fmp[j]%fmp[i]==0&&i!=j)
				add_edge(i,j);
	}
	spfa(n,n+1);
	int now=0;
	if(use[0])
	{
		cout<<-dis[0]<<endl;
		now=pre[now];
	}
	else
		cout<<1-dis[0]<<endl;
	while(pre[now]!=now)
	{
		if (debug)
			cout<<now<<"  "<<fmp[now]<<"  "<<mp[fmp[now]].size()<<endl;
		for(int i=0;i<mp[fmp[now]].size();i++)
			ans.push_back(mp[fmp[now]][i]);
		now=pre[now];
	}
	if (debug)
	{
		cout<<ans.size()<<endl;
		for(int i=ans.size()-1;i>=0;i--)
			cout<<ans[i]<<' ';
		cout<<endl;
	}
	long long int pj=1;
	for(int i=ans.size()-1;i>=0;i--)
	{
		long long tmp;
		modsolve(pj,ans[i],m,tmp);
		while(tmp<0)
			tmp+=m;
		tmp=tmp%m;
		pj=(pj*tmp)%m;
		if(use[pj])
		{
			cout<<tmp<<' '<<pj<<' '<<ans[i]<<"wa\n";
			break;
		}
		else
			use[pj]=true;
		if (0)
			printf("%d:%d ",tmp,pj);
		else if(i)
			printf("%d ",tmp);
		else
			printf("%d\n",tmp);
	}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
const int MAXN = 200020;
const int INF=0x3f3f3f3f;
bool use[200020]={0};
map<int,vector<int> > mp;
vector<int> fmp;
vector<int> con[130];
#define PB(X) push_back(X)
#define MP(X,Y) make_pair(X,Y)
typedef pair<int,int> PII ;
typedef vector<PII> VII ;

#define INF 0x3FFFFFFF
vector<int> G[MAXN];
void add_edge(int u,int v)
{
    G[u].PB(v);
}
void init(int n){
    for(int i=0;i<n;i++)
		G[i].clear();
}
int vis[MAXN];
int dis[MAXN];
int pre[MAXN];
void spfa(int s,int n)
{
    for(int i = 0;i<n;i++)
		dis[i] = (i == s ? 0 : INF);
    memset(vis,0,sizeof(vis));
	pre[s]=s;
    queue<int>q;
    q.push(s);
    while(!q.empty())
	{
        int x = q.front();
        q.pop();
        vis[x] = 0;
        for(int i = 0;i<G[x].size();i++)
		{
            int y = G[x][i];
            int d =-mp[x].size();
            if(dis[y] > dis[x] + d)
			{
                dis[y] = dis[x] + d;
				pre[y]=x;
                if(!vis[y])
				{
                    q.push(y);
                    vis[y] = 1;
                }
            }
        }
    }
}

int gcd(int a,int b)
{
	return (b==0)?a:gcd(b, a%b);
}

void extgcd(int a,int b,int &d,int &x,int &y)//扩展欧几里得
{

	if(!b)
	{
		d=a;x=1;y=0;
	}
	else
	{
		extgcd(b,a%b,d,y,x);
		y-=x*(a/b);
	}
}

bool modsolve(int a,int b,int m,int &x)
{
	int d,x0,y0;
	extgcd(a,m,d,x0,y0);
	if (b%d==0)
	{
		x=x0*b/d;
		return true;
	}
	return false;
}

vector<int> ans;
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		use[a]=true;
	}
	mp[0].push_back(0);
	fmp.push_back(0);
	for(int i=1;i<m;i++)
		if(!use[i])
		{
			int g=gcd(i,m);
			mp[g].push_back(i);
			if(mp[g].size()==1)
				fmp.push_back(g);
		}
	/*cout<<mp.size()<<endl;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		cout<<it->first<<"   "<<it->second<<endl;
	}*/
	n=fmp.size();
	mp[m].clear();
	fmp.push_back(m);
	init(n+1);
	add_edge(n,0);
	for(int i=1;i<n;i++)
	{
		add_edge(n,i);
		add_edge(i,0);
		for(int j=i+1;j<n;j++)
			if(fmp[j]%fmp[i]==0)
				add_edge(i,j);
	}
	spfa(n,n+1);
	if(use[0])
		cout<<-dis[0]<<endl;
	else
		cout<<1-dis[0]<<endl;
	int now=0;
	while(pre[now]!=now)
	{
		//cout<<now<<"  "<<fmp[now]<<"  "<<mp[fmp[now]].size()<<endl;
		for(int i=0;i<mp[fmp[now]].size();i++)
			ans.push_back(mp[fmp[now]][i]);
		now=pre[now];
	}
	/*for(int i=ans.size()-1;i>=0;i--)
		cout<<ans[i]<<' ';
	cout<<endl;*/
	int pj=1;
	if(use[0])
		ans.erase(ans.begin());
	for(int i=ans.size()-1;i>=0;i--)
	{
		int tmp;
		modsolve(pj,ans[i],m,tmp);
		while(tmp<0)
			tmp+=m;
		tmp=tmp%m;
		pj=(pj*tmp)%m;
		//printf("%d %d\n",tmp,pj);
		if(i)
			printf("%d ",tmp);
		else
			printf("%d\n",tmp);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
using namespace std;
const int MAXN = 200020;
const int INF=0x3f3f3f3f;
bool use[200020]={0};
map<int,vector<int> > mp;
vector<int> fmp;
vector<int> con[130];
#define PB(X) push_back(X)
#define MP(X,Y) make_pair(X,Y)
typedef pair<int,int> PII ;
typedef vector<PII> VII ;

#define INF 0x3FFFFFFF
vector<int> G[MAXN];
void add_edge(int u,int v)
{
    G[u].PB(v);
}
void init(int n){
    for(int i=0;i<n;i++)
		G[i].clear();
}
int vis[MAXN];
int dis[MAXN];
int pre[MAXN];
void spfa(int s,int n)
{
    for(int i = 0;i<n;i++)
		dis[i] = (i == s ? 0 : INF);
    memset(vis,0,sizeof(vis));
	pre[s]=s;
    queue<int>q;
    q.push(s);
    while(!q.empty())
	{
        int x = q.front();
        q.pop();
        vis[x] = 0;
        for(int i = 0;i<G[x].size();i++)
		{
            int y = G[x][i];
            int d =-mp[x].size();
            if(dis[y] > dis[x] + d)
			{
                dis[y] = dis[x] + d;
				pre[y]=x;
                if(!vis[y])
				{
                    q.push(y);
                    vis[y] = 1;
                }
            }
        }
    }
}

void extgcd(int a,int b,int &d,int &x,int &y)//扩展欧几里得
{

	if(!b)
	{
		d=a;x=1;y=0;
	}
	else
	{
		extgcd(b,a%b,d,y,x);
		y-=x*(a/b);
	}
}

bool modsolve(int a,int b,int m,int &x)
{
	int d,x0,y0;
	extgcd(a,m,d,x0,y0);
	if (b%d==0)
	{
		x=x0*b/d;
		return true;
	}
	return false;
}

vector<int> ans;
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		use[a]=true;
	}
	mp[0].push_back(0);
	fmp.push_back(0);
	for(int i=1;i<m;i++)
		if(!use[i])
		{
			int g=__gcd(i,m);
			mp[g].push_back(i);
			if(mp[g].size()==1)
				fmp.push_back(g);
		}
	/*cout<<mp.size()<<endl;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		cout<<it->first<<"   "<<it->second<<endl;
	}*/
	n=fmp.size();
	mp[m].clear();
	fmp.push_back(m);
	init(n+1);
	add_edge(n,0);
	for(int i=1;i<n;i++)
	{
		add_edge(n,i);
		add_edge(i,0);
		for(int j=i+1;j<n;j++)
			if(fmp[j]%fmp[i]==0)
				add_edge(i,j);
	}
	spfa(n,n+1);
	if(use[0])
		cout<<-dis[0]<<endl;
	else
		cout<<1-dis[0]<<endl;
	int now=0;
	while(pre[now]!=now)
	{
		//cout<<now<<"  "<<fmp[now]<<"  "<<mp[fmp[now]].size()<<endl;
		for(int i=0;i<mp[fmp[now]].size();i++)
			ans.push_back(mp[fmp[now]][i]);
		now=pre[now];
	}
	/*for(int i=ans.size()-1;i>=0;i--)
		cout<<ans[i]<<' ';
	cout<<endl;*/
	int pj=1;
	if(use[0])
		ans.erase(ans.begin());
	for(int i=ans.size()-1;i>=0;i--)
	{
		int tmp;
		modsolve(pj,ans[i],m,tmp);
		while(tmp<0)
			tmp+=m;
		pj=(pj*tmp)%m;
		//printf("%d %d\n",tmp,pj);
		if(i)
			printf("%d ",tmp);
		else
			printf("%d\n",tmp);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
const int debug=0;
using namespace std;
const int MAXN = 200020;
const int INF=0x3f3f3f3f;
bool use[200020]={0};
map<int,vector<int> > mp;
vector<int> fmp;
vector<int> con[130];
#define PB(X) push_back(X)
#define MP(X,Y) make_pair(X,Y)
typedef pair<int,int> PII ;
typedef vector<PII> VII ;

#define INF 0x3FFFFFFF
vector<int> G[MAXN];
void add_edge(int u,int v)
{
    G[u].PB(v);
}
void init(int n){
    for(int i=0;i<n;i++)
		G[i].clear();
}
int vis[MAXN];
int dis[MAXN];
int pre[MAXN];
void spfa(int s,int n)
{
    for(int i = 0;i<n;i++)
		dis[i] = (i == s ? 0 : INF);
    memset(vis,0,sizeof(vis));
	pre[s]=s;
    queue<int>q;
    q.push(s);
    while(!q.empty())
	{
        int x = q.front();
        q.pop();
        vis[x] = 0;
        for(int i = 0;i<G[x].size();i++)
		{
            int y = G[x][i];
            int d =-mp[fmp[x]].size();
            if(dis[y] > dis[x] + d)
			{
                dis[y] = dis[x] + d;
				pre[y]=x;
                if(!vis[y])
				{
                    q.push(y);
                    vis[y] = 1;
                }
            }
        }
    }
}

int gcd(int a,int b)
{
	return (b==0)?a:gcd(b, a%b);
}

void extgcd(long long a,long long b,long long &d,long long &x,long long &y)//扩展欧几里得
{

	if(!b)
	{
		d=a;x=1;y=0;
	}
	else
	{
		extgcd(b,a%b,d,y,x);
		y-=x*(a/b);
	}
}

bool modsolve(long long a,long long b,long long m,long long &x)
{
	long long d,x0,y0;
	extgcd(a,m,d,x0,y0);
	if (b%d==0)
	{
		x=x0*b/d;
		return true;
	}
	return false;
}

vector<int> ans;
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		use[a]=true;
	}
	mp[0].push_back(0);
	fmp.push_back(0);
	for(int i=1;i<m;i++)
		if(!use[i])
		{
			int g=gcd(i,m);
			mp[g].push_back(i);
			if(mp[g].size()==1)
				fmp.push_back(g);
		}
	if (debug)
	{
		cout<<mp.size()<<endl;
		for(map<int,vector<int> >::iterator it=mp.begin();it!=mp.end();it++)
		{
			cout<<it->first<<"   "<<it->second.size()<<endl;
		}
	}
	n=fmp.size();
	mp[m].clear();
	fmp.push_back(m);
	init(n+1);
	add_edge(n,0);
	for(int i=1;i<n;i++)
	{
		add_edge(n,i);
		add_edge(i,0);
		for(int j=i+1;j<n;j++)
			if(fmp[j]%fmp[i]==0)
				add_edge(i,j);
	}
	spfa(n,n+1);
	int now=0;
	if(use[0])
	{
		cout<<-dis[0]<<endl;
		now=pre[now];
	}
	else
		cout<<1-dis[0]<<endl;
	while(pre[now]!=now)
	{
		if (debug)
			cout<<now<<"  "<<fmp[now]<<"  "<<mp[fmp[now]].size()<<endl;
		for(int i=0;i<mp[fmp[now]].size();i++)
			ans.push_back(mp[fmp[now]][i]);
		now=pre[now];
	}
	if (debug)
	{
		cout<<ans.size()<<endl;
		for(int i=ans.size()-1;i>=0;i--)
			cout<<ans[i]<<' ';
		cout<<endl;
	}
	long long int pj=1;
	for(int i=ans.size()-1;i>=0;i--)
	{
		long long tmp;
		modsolve(pj,ans[i],m,tmp);
		while(tmp<0)
			tmp+=m;
		tmp=tmp%m;
		pj=(pj*tmp)%m;
		if(use[pj])
		{
			cout<<tmp<<' '<<pj<<' '<<ans[i]<<"wa\n";
			break;
		}
		else
			use[pj]=true;
		if (0)
			printf("%d:%d ",tmp,pj);
		else if(i)
			printf("%d ",tmp);
		else
			printf("%d\n",tmp);
	}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
using namespace std;
const int N = int(3e5) + 10, mod = int(1e9)  + 7;

int n,m;

bool bad[N];

vi g[N], di, rb;
int cnt[N];

int dp[N], from[N];

ll modpow(ll a,ll b, ll c){
	ll res = 1;
	while(b){
		if(b & 1) res =  res * a % c;
		a = a * a % c;
		b >>= 1;
	}
	return res % c;
}

int phi(int n){
	int m = n;
	for(int i=2;i*i<=n;i++){
		if(n%i == 0){
			while(n%i == 0){
				n /= i;
			}
			m -= m/i;
		}
	}
	if (n > 1) m -= m/n;
	return m;
}

int main () {
	scanf("%d%d",&n,&m);
	for(int i = 1,x; i <= n; i++){
		scanf("%d",&x);
		bad[x] = 1;
	}
	for(int i = 0; i < m; i++){
		if(!bad[i]){
			int d = __gcd(i,m);
			g[d].pb(i);
			cnt[d]++;
		}
	}
	for(int i = 1; i <= m; i++){
		if(m % i == 0) di.pb(i);
	}

	int mx = 0, c = 0;
	dp[0] = cnt[di[0]];
	from[0] = -1;
	c = 0;
	mx = dp[0];
	for(int i = 1; i < di.size(); i++){
		int x = di[i];
		dp[i] = 0;
		from[i] = -1;
		for(int j = 0; j < i; j++){
			if(x % di[j] == 0){
				if(dp[i] < dp[j]){
					dp[i] = dp[j];
					from[i] = j;
				}
			}
		}
		dp[i] += cnt[di[i]];
		if(mx < dp[i]){
			mx = dp[i];
			c = i;
		}
	}
	printf("%d\n", mx);
	while(c != -1){
		for(int i = 0; i < g[di[c]].size(); i++){
			rb.pb(g[di[c]][i]);
		}
		c = from[c];
	}
	reverse(rb.begin(), rb.end());
	int ph = phi(m);
	printf("%d ", rb[0]);
	int pref = rb[0];
	for(int i = 1; i < rb.size(); i++){
		int y = rb[i - 1];
		int x = rb[i];
		int gd = __gcd(x,y);
		x /= gd;
		y /= gd;
		pref = pref *(1ll* x * modpow(y, ph - 1, m) % m) % m;
		printf("%d ",1ll*x * modpow(y, ph - 1, m) % m);
	}
return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
using namespace std;
const int N = int(3e5) + 10, mod = int(1e9)  + 7;

int n,m;

bool bad[N];

vi g[N], di, rb;
int cnt[N];

int dp[N], from[N];

ll modpow(ll a,ll b, ll c){
	ll res = 1;
	while(b){
		if(b & 1) res =  res * a % c;
		a = a * a % c;
		b >>= 1;
	}
	return res % c;
}

int phi(int n){
	int m = n;
	for(int i=2;i*i<=n;i++){
		if(n%i == 0){
			while(n%i == 0){
				n /= i;
			}
			m -= m/i;
		}
	}
	if (n > 1) m -= m/n;
	return m;
}

int main () {
	scanf("%d%d",&n,&m);
	for(int i = 1,x; i <= n; i++){
		scanf("%d",&x);
		bad[x] = 1;
	}
	for(int i = 0; i < m; i++){
		if(!bad[i]){
			int d = __gcd(i,m);
			g[d].pb(i);
			cnt[d]++;
		}
	}
	for(int i = 1; i <= m; i++){
		if(m % i == 0) di.pb(i);
	}

	int mx = 0, c = 0;
	dp[0] = cnt[di[0]];
	from[0] = -1;
	c = 0;
	mx = dp[0];
	for(int i = 1; i < di.size(); i++){
		int x = di[i];
		dp[i] = 0;
		from[i] = -1;
		for(int j = 0; j < i; j++){
			if(x % di[j] == 0){
				if(dp[i] < dp[j]){
					dp[i] = dp[j];
					from[i] = j;
				}
			}
		}
		dp[i] += cnt[di[i]];
		if(mx < dp[i]){
			mx = dp[i];
			c = i;
		}
	}
	printf("%d\n", mx);
	while(c != -1){
		for(int i = 0; i < g[di[c]].size(); i++){
			rb.pb(g[di[c]][i]);
		}
		c = from[c];
	}
	reverse(rb.begin(), rb.end());
	int ph = phi(m);
	printf("%d ", rb[0]);
	int pref = rb[0];
	for(int i = 1; i < rb.size(); i++){
		int y = rb[i - 1];
		int x = rb[i];
		pref = pref *(1ll*x * modpow(y, ph - 1, m) % m) % m;
		printf("%d ",1ll*x * modpow(y, ph - 1, m) % m);
	}
return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int n, m;

bool forbidden[200100], cp[200100];

bool read() {
	if (scanf("%d%d", &n, &m) != 2) {
		return false;
	}
	forbidden[m] = true;
	for (int i = 0; i < m; i++) {
		forbidden[i] = cp[i] = false;
	}
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		forbidden[a] = true;
	}

	return true;
}

pair<long long, long long> euc(int a, int b) {
	if (b==0) return pair<long long,long long>(1,0);
	pair<long long,long long> rec = euc(b, a%b);
	return pair<long long,long long>(rec.second, rec.first - (a/b)* rec.second);
}

int inv(int a, int n) {
	return ((euc(a, n).first % n) + n) % n;
}

int gcd(int a, int b) {
	if (b > a) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}

vector<int> prods[200100];
int pd[200100];
int parent[200100];

void process() {
	for (int i = 1; i < m; i++) {
		prods[i].clear();
		if (!forbidden[i]) {
			int g = gcd(i, m);
			prods[g].push_back(i);
		}
	}
	pd[1] = prods[1].size();
	parent[1] = -1;
	int best = 1;
	for (int i = 2; i < m; i++) {
		if (m % i == 0) {
			pd[i] = prods[i].size();
			parent[i] = -1;
			for (int k = 1; k < i; k++) {
				if (i % k == 0) {
					if (pd[i] < prods[i].size() + pd[k]) {
						pd[i] = pd[k] + prods[i].size();
						parent[i] = k;
					}
				}
			}
			if (pd[best] < pd[i]) {
				best = i;
			}
		}
	}
	vector<int> ps;
	while(best != -1) {
		for(vector<int>::iterator it = prods[best].begin(); it != prods[best].end(); it++) {
			ps.push_back(*it);
		}
		best = parent[best];
	}
	reverse(ps.begin(), ps.end());
	if (!forbidden[0]) {
		ps.push_back(0);
	}
	int cur_prod = 1;

	bool first = true;
	printf("%d\n", (int) ps.size());
	int prod_sofar = 1;
	for (vector<int>::iterator it = ps.begin(); it != ps.end(); it++) {
		int cur;
		int g = gcd(cur_prod, m);
		//printf("gcd(%d,%d) = %d\n", cur_prod, *it, g);
		if (g == 1) {
			cur = (inv(cur_prod, m) * ((long long) *it)) % m;
		} else {

			cur = (inv(cur_prod / g, m/ g) * ((long long) *it / g)) % m;
		}
		if (first) {
			first = false;
		} else {
			printf(" ");
		}
		prod_sofar = (prod_sofar * ((long long) cur)) % m;
		//printf("(%d, %d, %d)\n", cur, *it, prod_sofar);
		printf("%d", cur);
		cur_prod = *it;
	}
	printf("\n");
}

int main() {
	bool first = true;
	while (read()) {
		if (first) {
			first = false;
		} else {
			printf("\n");
		}
		process();
	}

	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int n, m;

bool forbidden[200100], cp[200100];

bool read() {
	if (scanf("%d%d", &n, &m) != 2) {
		return false;
	}
	forbidden[m] = true;
	for (int i = 0; i < m; i++) {
		forbidden[i] = cp[i] = false;
	}
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		forbidden[a] = true;
	}

	return true;
}

pair<long long, long long> euc(int a, int b) {
	if (b==0) return pair<long long,long long>(1,0);
	pair<long long,long long> rec = euc(b, a%b);
	return pair<long long,long long>(rec.second, rec.first - (a/b)* rec.second);
}

int inv(int a, int n) {
	return ((euc(a, n).first % n) + n) % n;
}

int gcd(int a, int b) {
	if (b > a) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}

vector<int> prods[200100];
int pd[200100];
int parent[200100];

void process() {
	for (int i = 1; i < m; i++) {
		prods[i].clear();
		if (!forbidden[i]) {
			int g = gcd(i, m);
			prods[g].push_back(i);
		}
	}
	pd[1] = prods[1].size();
	parent[1] = -1;
	int best = 1;
	for (int i = 2; i < m; i++) {
		if (m % i == 0) {
			pd[i] = prods[i].size();
			parent[i] = -1;
			for (int k = 1; k < i; k++) {
				if (i % k == 0) {
					if (pd[i] < prods[i].size() + pd[k]) {
						pd[i] = pd[k] + prods[i].size();
						parent[i] = k;
					}
				}
			}
			if (pd[best] < pd[i]) {
				best = i;
			}
		}
	}
	vector<int> ps;
	while(best != -1) {
		for(vector<int>::iterator it = prods[best].begin(); it != prods[best].end(); it++) {
			ps.push_back(*it);
		}
		best = parent[best];
	}
	reverse(ps.begin(), ps.end());
	if (!forbidden[0]) {
		ps.push_back(0);
	}
	int cur_prod = 1;

	bool first = true;
	printf("%d\n", (int) ps.size());
	for (vector<int>::iterator it = ps.begin(); it != ps.end(); it++) {
		int cur;
		int g = gcd(cur_prod, *it);
		if (g == 1) {
			cur = (inv(cur_prod, m) * ((long long) *it)) % m;
		} else {
			cur = (inv(cur_prod / g, m/ g) * ((long long) *it / g)) % m;
		}
		if (first) {
			first = false;
		} else {
			printf(" ");
		}
		printf("%d", cur);
		cur_prod = *it;
	}
	printf("\n");
}

int main() {
	bool first = true;
	while (read()) {
		if (first) {
			first = false;
		} else {
			printf("\n");
		}
		process();
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b)for(int i=(a),i##_end_=(b);i<i##_end_;++i)
#define PER(i,a,b)for(int i=(b)-1,i##_end_=(a);i>=i##_end_;--i)
#define pb push_back
#define fi first
#define se second
template<class T>inline bool umx(T& A,const T& B){return A<B?A=B,1:0;}
template<class T>inline bool umn(T& A,const T& B){return A>B?A=B,1:0;}
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
typedef pair<db,int> PDI;

const int maxn=1010;

// =============== Number Theory ===============
void exgcd(LL a,LL b,LL&d,LL&x,LL&y){
	if(!b)d=a,x=1,y=0;
	else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
LL inv(LL a,LL M){
	LL d,x,y;exgcd(a,M,d,x,y);
	return d!=1 ? -1 : (x<0 ? x+M : x);
}

vector<int> a[maxn];
int f[maxn],v[maxn],p[maxn];
bool mark[maxn];
int n,m;

vector<int> ans;
void dfs(int n){
	if(n==0)return;
	for(auto&x:a[n])if(!mark[x])ans.pb(x);
	dfs(p[n]);
}

int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	REP(i,0,m){
		int x=__gcd(i,m);
		a[x].pb(i);
		++v[x];
	}
	REP(i,0,n){
		int x;scanf("%d",&x);
		mark[x]=1;
		x=__gcd(x,m);
		--v[x];
	}
	REP(i,1,m+1)for(int j=i+i;j<=m;j+=i){
		if(umx(f[j],f[i]+v[i]))p[j]=i;
	}
//	REP(i,1,m+1)printf("%d %d\n",f[i],p[i]);putchar('\n');
	dfs(m);
	reverse(ans.begin(),ans.end());
//	for(auto&x:ans)printf("%d ",x);putchar('\n');

	printf("%d\n",f[m]+1);
	int now=1,nowg=1,lst=1;
	for(auto&x:ans){
		now=(inv(lst/nowg,m/nowg)*(x/nowg))%m;
		lst=x;
		nowg=__gcd(now,m);
		printf("%d ",now);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b)for(int i=(a),i##_end_=(b);i<i##_end_;++i)
#define PER(i,a,b)for(int i=(b)-1,i##_end_=(a);i>=i##_end_;--i)
#define pb push_back
#define fi first
#define se second
template<class T>inline bool umx(T& A,const T& B){return A<B?A=B,1:0;}
template<class T>inline bool umn(T& A,const T& B){return A>B?A=B,1:0;}
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
typedef pair<db,int> PDI;

const int maxn=1010;

// =============== Number Theory ===============
void exgcd(LL a,LL b,LL&d,LL&x,LL&y){
	if(!b)d=a,x=1,y=0;
	else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
LL inv(LL a,LL M){
	LL d,x,y;exgcd(a,M,d,x,y);
	return d!=1 ? -1 : (x<0 ? x+M : x);
}

vector<int> a[maxn];
int f[maxn],v[maxn],p[maxn];
bool mark[maxn];
int n,m;

vector<int> ans;
void dfs(int n){
	if(n==0)return;
	for(auto&x:a[n])if(!mark[x])ans.pb(x);
	dfs(p[n]);
}
vector<int> divs;
int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	REP(i,0,m){
		int x=__gcd(i,m);
		divs.pb(x);
		a[x].pb(i);
		++v[x];
	}
	sort(divs.begin(),divs.end());
	divs.erase(unique(divs.begin(),divs.end()),divs.end());
	REP(i,0,n){
		int x;scanf("%d",&x);
		mark[x]=1;
		x=__gcd(x,m);
		--v[x];
	}
	for(int ki=0;ki<divs.size();++ki){
		int i=divs[ki];
		for(int k=1,j;k<divs.size()&&(j=i*divs[k])<=m;++k)
			if(umx(f[j],f[i]+v[i]))p[j]=i;
	}
	f[m]+=v[m];
//	REP(i,1,m+1)printf("%d %d\n",f[i],p[i]);putchar('\n');

	int mxi=max_element(f+1,f+1+m)-f;
	dfs(mxi);
	reverse(ans.begin(),ans.end());
//	for(auto&x:ans)printf("%d ",x);putchar('\n');

	printf("%d\n",f[mxi]);
	int now=1,nowg=1,lst=1;
	for(auto&x:ans){
		now=(inv(lst/nowg,m/nowg)*(x/nowg))%m;
		lst=x;
		nowg=__gcd(now,m);
		printf("%d ",now);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b)for(int i=(a),i##_end_=(b);i<i##_end_;++i)
#define PER(i,a,b)for(int i=(b)-1,i##_end_=(a);i>=i##_end_;--i)
#define pb push_back
#define fi first
#define se second
template<class T>inline bool umx(T& A,const T& B){return A<B?A=B,1:0;}
template<class T>inline bool umn(T& A,const T& B){return A>B?A=B,1:0;}
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
typedef pair<db,int> PDI;

const int maxn=1010;

// =============== Number Theory ===============
void exgcd(LL a,LL b,LL&d,LL&x,LL&y){
	if(!b)d=a,x=1,y=0;
	else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
LL inv(LL a,LL M){
	LL d,x,y;exgcd(a,M,d,x,y);
	return d!=1 ? -1 : (x<0 ? x+M : x);
}

vector<int> a[maxn];
int f[maxn],v[maxn],p[maxn];
bool mark[maxn];
int n,m;

vector<int> ans;
void dfs(int n){
	if(n==0)return;
	for(auto&x:a[n])if(!mark[x])ans.pb(x);
	dfs(p[n]);
}

int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	REP(i,0,m){
		int x=__gcd(i,m);
		a[x].pb(i);
		++v[x];
	}
	REP(i,0,n){
		int x;scanf("%d",&x);
		mark[x]=1;
		x=__gcd(x,m);
		--v[x];
	}
	REP(i,1,m+1)for(int j=i+i;j<=m;j+=i){
		if(umx(f[j],f[i]+v[i]))p[j]=i;
	}
//	REP(i,1,m+1)printf("%d %d\n",f[i],p[i]);putchar('\n');
	dfs(m);
	reverse(ans.begin(),ans.end());
//	for(auto&x:ans)printf("%d ",x);putchar('\n');

	printf("%d\n",f[m]+1);
	int now=1,nowg=1,lst=1;
	for(auto&x:ans){
		now=(inv(lst/nowg,m/nowg)*x)%m;
		lst=x;
		nowg=__gcd(now,m);
		printf("%d ",now);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b)for(int i=(a),i##_end_=(b);i<i##_end_;++i)
#define PER(i,a,b)for(int i=(b)-1,i##_end_=(a);i>=i##_end_;--i)
#define pb push_back
#define fi first
#define se second
template<class T>inline bool umx(T& A,const T& B){return A<B?A=B,1:0;}
template<class T>inline bool umn(T& A,const T& B){return A>B?A=B,1:0;}
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
typedef pair<db,int> PDI;

const int maxn=1010;

// =============== Number Theory ===============
void exgcd(LL a,LL b,LL&d,LL&x,LL&y){
	if(!b)d=a,x=1,y=0;
	else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
LL inv(LL a,LL M){
	LL d,x,y;exgcd(a,M,d,x,y);
	return d!=1 ? -1 : (x<0 ? x+M : x);
}

vector<int> a[maxn];
int f[maxn],v[maxn],p[maxn];
bool mark[maxn];
int n,m;

vector<int> ans;
void dfs(int n){
	if(n==0)return;
	for(auto&x:a[n])if(!mark[x])ans.pb(x);
	dfs(p[n]);
}

int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	REP(i,0,m){
		int x=__gcd(i,m);
		a[x].pb(i);
		++v[x];
	}
	REP(i,0,n){
		int x;scanf("%d",&x);
		mark[x]=1;
		x=__gcd(x,m);
		--v[x];
	}
	REP(i,1,m+1)for(int j=i+i;j<=m;j+=i){
		if(umx(f[j],f[i]+v[i]))p[j]=i;
	}
	f[m]+=v[m];
//	REP(i,1,m+1)printf("%d %d\n",f[i],p[i]);putchar('\n');
	dfs(m);
	reverse(ans.begin(),ans.end());
//	for(auto&x:ans)printf("%d ",x);putchar('\n');

	printf("%d\n",f[m]);
	int now=1,lst=1;
	for(auto&x:ans){
		int g=__gcd(lst,m);
		now=(inv(lst/g,m/g)*(x/g))%m;
		lst=x;
		printf("%d ",now);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b)for(int i=(a),i##_end_=(b);i<i##_end_;++i)
#define PER(i,a,b)for(int i=(b)-1,i##_end_=(a);i>=i##_end_;--i)
#define pb push_back
#define fi first
#define se second
template<class T>inline bool umx(T& A,const T& B){return A<B?A=B,1:0;}
template<class T>inline bool umn(T& A,const T& B){return A>B?A=B,1:0;}
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
typedef pair<db,int> PDI;

const int maxn=1010;

// =============== Number Theory ===============
void exgcd(LL a,LL b,LL&d,LL&x,LL&y){
	if(!b)d=a,x=1,y=0;
	else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
LL inv(LL a,LL M){
	LL d,x,y;exgcd(a,M,d,x,y);
	return d!=1 ? -1 : (x<0 ? x+M : x);
}

vector<int> a[maxn];
int f[maxn],v[maxn],p[maxn];
bool mark[maxn];
int n,m;

vector<int> ans;
void dfs(int n){
	if(n==0)return;
	for(auto&x:a[n])if(!mark[x])ans.pb(x);
	dfs(p[n]);
}

int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	REP(i,0,m){
		int x=__gcd(i,m);
		a[x].pb(i);
		++v[x];
	}
	REP(i,0,n){
		int x;scanf("%d",&x);
		mark[x]=1;
		x=__gcd(x,m);
		--v[x];
	}
	REP(i,1,m+1)for(int j=i+i;j<=m;j+=i){
		if(umx(f[j],f[i]+v[i]))p[j]=i;
	}
//	REP(i,1,m+1)printf("%d %d\n",f[i],p[i]);putchar('\n');
	dfs(m);
	reverse(ans.begin(),ans.end());
//	for(auto&x:ans)printf("%d ",x);putchar('\n');

	printf("%d\n",f[m]+v[m]);
	int now=1,nowg=1,lst=1;
	for(auto&x:ans){
		now=(inv(lst/nowg,m/nowg)*(x/nowg))%m;
		lst=x;
		nowg=__gcd(now,m);
		printf("%d ",now);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b)for(int i=(a),i##_end_=(b);i<i##_end_;++i)
#define PER(i,a,b)for(int i=(b)-1,i##_end_=(a);i>=i##_end_;--i)
#define pb push_back
#define fi first
#define se second
template<class T>inline bool umx(T& A,const T& B){return A<B?A=B,1:0;}
template<class T>inline bool umn(T& A,const T& B){return A>B?A=B,1:0;}
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
typedef pair<db,int> PDI;

const int maxn=1010;

// =============== Number Theory ===============
void exgcd(LL a,LL b,LL&d,LL&x,LL&y){
	if(!b)d=a,x=1,y=0;
	else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
LL inv(LL a,LL M){
	LL d,x,y;exgcd(a,M,d,x,y);
	return d!=1 ? -1 : (x<0 ? x+M : x);
}

vector<int> a[maxn];
int f[maxn],v[maxn],p[maxn];
bool mark[maxn];
int n,m;

vector<int> ans;
void dfs(int n){
	if(n==0)return;
	for(auto&x:a[n])if(!mark[x])ans.pb(x);
	dfs(p[n]);
}

int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	REP(i,0,m){
		int x=__gcd(i,m);
		a[x].pb(i);
		++v[x];
	}
	REP(i,0,n){
		int x;scanf("%d",&x);
		mark[x]=1;
		--v[x];
	}
	REP(i,1,m+1)for(int j=i+i;j<=m;j+=i){
		if(umx(f[j],f[i]+v[i]))p[j]=i;
	}
//	REP(i,1,m+1)printf("%d %d\n",f[i],p[i]);putchar('\n');
	dfs(m);
	reverse(ans.begin(),ans.end());
//	for(auto&x:ans)printf("%d ",x);putchar('\n');

	printf("%d\n",f[m]+1);
	int now=1,nowg=1,lst=1;
	for(auto&x:ans){
		now=(inv(lst/nowg,m/nowg)*x)%m;
		lst=x;
		nowg=__gcd(now,m);
		printf("%d ",now);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b)for(int i=(a),i##_end_=(b);i<i##_end_;++i)
#define PER(i,a,b)for(int i=(b)-1,i##_end_=(a);i>=i##_end_;--i)
#define pb push_back
#define fi first
#define se second
template<class T>inline bool umx(T& A,const T& B){return A<B?A=B,1:0;}
template<class T>inline bool umn(T& A,const T& B){return A>B?A=B,1:0;}
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
typedef pair<db,int> PDI;

const int maxn=200010;

// =============== Number Theory ===============
void exgcd(LL a,LL b,LL&d,LL&x,LL&y){
	if(!b)d=a,x=1,y=0;
	else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
LL inv(LL a,LL M){
	LL d,x,y;exgcd(a,M,d,x,y);
	return d!=1 ? -1 : (x<0 ? x+M : x);
}

vector<int> a[maxn];
int f[maxn],v[maxn],p[maxn];
bool mark[maxn];
int n,m;

vector<int> ans;
void dfs(int n){
	if(n==0)return;
	for(auto&x:a[n])if(!mark[x])ans.pb(x);
	dfs(p[n]);
}

int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	REP(i,0,m){
		int x=__gcd(i,m);
		a[x].pb(i);
		++v[x];
	}
	REP(i,0,n){
		int x;scanf("%d",&x);
		mark[x]=1;
		x=__gcd(x,m);
		--v[x];
	}
	REP(i,1,m+1)for(int j=i+i;j<=m;j+=i){
		if(umx(f[j],f[i]+v[i]))p[j]=i;
	}
	f[m]+=v[m];
//	REP(i,1,m+1)printf("%d %d\n",f[i],p[i]);putchar('\n');
	dfs(m);
	reverse(ans.begin(),ans.end());
//	for(auto&x:ans)printf("%d ",x);putchar('\n');

	printf("%d\n",f[m]);
	int now=1,lst=1;
	for(auto&x:ans){
		int g=__gcd(lst,m);
		now=(inv(lst/g,m/g)*(x/g))%m;
		lst=x;
		printf("%d ",now);
	}

	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans,v[1000001],a[1000001],sz[1000001],f[1000001],nt[1000001];
vector<ll>zh[200001];
ll gcd(ll x,ll y){
	if(!y)return x;
	return gcd(y,x%y);
}
ll exgcd(ll a,ll b,ll &x,ll &y){
	if(!b){
		x=1;y=0;
		return a;
	}
	ll t,hh=exgcd(b,a%b,x,y);
	t=x;x=y;y=t-a/b*y;
	return hh;
}
ll work(ll aa,ll bb){
	ll x,y,hh=exgcd(aa,m,x,y);
	x=((x+m)%m*bb/hh)%m;
	return x;
}
void get(ll x,ll la){
	ll i;
	for(i=0;i<zh[x].size();i++){
		ans=work(la,zh[x][i]);
		printf("%lld ",ans);
		la=zh[x][i];
	}
	if(nt[x])get(nt[x],la);
}
int main(){
	ll i,j,x;
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%lld",&x);
		v[x]=1;
	}
	for(i=1;i<m;i++)if(!v[i]){
		x=gcd(i,m);
		sz[x]++;
		zh[x].push_back(i);
	}
	for(i=m/2;i;i--)if(sz[i]){
		for(j=i*2;j<=m;j+=i)if(f[j]&&f[j]>f[i]){
			f[i]=f[j];
			nt[i]=j;
		}
		f[i]+=sz[i];
	}
	ans=f[1];
	if(!v[0])ans++;
	printf("%lld\n",ans);
	get(1,1);
	if(!v[0])puts("0");
//
}


#include<bits/stdc++.h>

using namespace std;

const int maxn = 200000 + 9;

int N, M;
int dp[maxn], p[maxn];
bool ok[maxn];
vector<int> g[maxn];

void Gcd(int a, int b, int &d, int &x, int &y) {
	if(!b) {
		d = a;
		x = 1;
		y = 0;
	} else {
		Gcd(b, a % b, d, y, x);
		y -= x * (a / b);
	}
}

int main() {
//    freopen("input.txt", "r", stdin);

    cin >> N >> M;
    for(int i = 0; i <= M; i++) {
        ok[i] = true;
        p[i] = dp[i] = 0;
    }
    while(N--) {
        int w;
        scanf("%d", &w);
        ok[w] = false;
    }
    for(int i = 1; i < M; i++) {
        if(ok[i]) {
            g[__gcd(i, M)].push_back(i);
        }
    }
    for(int i = 1; i <= M; i++) {
        dp[i] += g[i].size();
        for(int j = i + i; j < M; j += i) {
            if(dp[i] > dp[j]) {
                dp[j] = dp[i];
                p[j] = i;
            }
        }
    }
    int V = max_element(dp, dp + M + 1) - dp;
    cout << dp[V] + ok[0] << endl;
    vector<int> ans;
    for(; V; V = p[V]) {
        for(auto e : g[V]) {
            ans.push_back(e);
        }
    }
    for(int i = (int) ans.size() - 1, p = 1; i >= 0; i--) {
        int d, x, y;
        Gcd(p, M, d, x, y);
        printf("%d ", ((p = ans[i]) / d * x % M + M) % M);
    }
    if(ok[0]) {
        puts("0");
    }

    return 0;
 }


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 200000 + 9;

int N, M;
int dp[maxn], p[maxn];
bool ok[maxn];
vector<int> g[maxn];

void Gcd(int a, int b, int &d, int &x, int &y) {
	if(!b) {
		d = a;
		x = 1;
		y = 0;
	} else {
		Gcd(b, a % b, d, y, x);
		y -= x * (a / b);
	}
}

int main() {
//    freopen("input.txt", "r", stdin);

    cin >> N >> M;
    for(int i = 0; i <= M; i++) {
        ok[i] = true;
        p[i] = dp[i] = 0;
    }
    while(N--) {
        int w;
        scanf("%d", &w);
        ok[w] = false;
    }
    for(int i = 1; i < M; i++) {
        if(ok[i]) {
            g[__gcd(i, M)].push_back(i);
        }
    }
    for(int i = 1; i <= M; i++) {
        dp[i] += g[i].size();
        for(int j = i + i; j < M; j += i) {
            if(dp[i] > dp[j]) {
                dp[j] = dp[i];
                p[j] = i;
            }
        }
    }
    int V = max_element(dp, dp + M + 1) - dp;
    cout << dp[V] + ok[0] << endl;
    vector<int> ans;
    for(; V; V = p[V]) {
        for(auto e : g[V]) {
            ans.push_back(e);
        }
    }
    int cur = 1;
    for(int i = (int) ans.size() - 1, p = 1; i >= 0; i--) {
        int d, x, y;
        Gcd(p, M, d, x, y);
	assert(ans[i] % d == 0);
        printf("%d ", (int) (ll(x) * ((p = ans[i]) / d) % M + M) % M);
    }
    if(ok[0]) {
        puts("0");
    }

    return 0;
 }


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

const int maxn = 2e5 + 5;
int dp[maxn], m, pd[maxn], par[maxn], pr[maxn];
vector <int> D[maxn];

bool cmp(int i, int j) {
	return __gcd(j, m) < __gcd(i, m);
}

int varoon(int a, int m) {
//	cout << a << ' ' << m << endl;
	if (a == 1)
		return 1;
//	cout << "H " << m % a << ' ' << a << endl;
	int x = varoon(m % a, a);
	return m - (((1ll * x * (m % a) - 1) / a + m / a * x) % m + m) % m;
}

int findx(int a, int b) {
	return ((varoon(a / __gcd(a, m), m / __gcd(a, m)) * b / __gcd(a, m)) % m + m) % m;
}

int main() {
	int n;
	cin >> n >> m;
	set <int> S;
	for (int i = 0; i < m; i++) {
		S.insert(i);
		for (int j = i + 1; j <= m; j += i + 1) {
			D[j].push_back(i + 1);
		}
	}
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		S.erase(a);
	}
	vector <int> M;
	for (auto i: S) {
		M.push_back(i);
	}
	sort(M.begin(), M.end(), cmp);
	fill(pr, pr + maxn, -1);
	for (int id = 0; id < m - n; id++) {
		int i = M[id];
		int x = dp[__gcd(i, m)] + 1;
		pd[i] = x;
		par[i] = pr[__gcd(i, m)];
		for (auto j: D[__gcd(i, m)]) {
			dp[j] = max(dp[j], x);
			if (dp[j] == x)
				pr[j] = i;
		}
	}
	cout << dp[1] << '\n';
	int j = pr[1];
	M.clear();
	M.push_back(1);
	while (~j) {
		M.push_back(j);
//		cout << j << endl;
		j = par[j];
	}
	for (int i = 0; i < (int)M.size() - 1; i++) {
		cout << findx(M[i], M[i + 1]) << ' ';
	}
}


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

const int maxn = 2e5 + 5;
int dp[maxn], m, pd[maxn], par[maxn], pr[maxn];
vector <int> D[maxn];

bool cmp(int i, int j) {
	return __gcd(j, m) < __gcd(i, m);
}

int varoon(int a, int m) {
//	cout << a << ' ' << m << endl;
	if (a == 1)
		return 1;
//	cout << "H " << m % a << ' ' << a << endl;
	int x = varoon(m % a, a);
	return m - (((1ll * x * (m % a) - 1) / a + m / a * x) % m);
}

int findx(int a, int b) {
	return ((varoon(a / __gcd(a, m), m / __gcd(a, m)) * b / __gcd(a, m)) % m + m) % m;
}

int main() {
	int n;
	cin >> n >> m;
	set <int> S;
	for (int i = 0; i < m; i++) {
		S.insert(i);
		for (int j = i + 1; j <= m; j += i + 1) {
			D[j].push_back(i + 1);
		}
	}
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		S.erase(a);
	}
	vector <int> M;
	for (auto i: S) {
		M.push_back(i);
	}
	sort(M.begin(), M.end(), cmp);
	fill(pr, pr + maxn, -1);
	for (int id = 0; id < m - n; id++) {
		int i = M[id];
		int x = dp[__gcd(i, m)] + 1;
		pd[i] = x;
		par[i] = pr[__gcd(i, m)];
		for (auto j: D[__gcd(i, m)]) {
			dp[j] = max(dp[j], x);
			if (dp[j] == x)
				pr[j] = i;
		}
	}
	cout << dp[1] << '\n';
	int j = pr[1];
	M.clear();
	M.push_back(1);
	while (~j) {
		M.push_back(j);
//		cout << j << endl;
		j = par[j];
	}
	for (int i = 0; i < (int)M.size() - 1; i++) {
		cout << findx(M[i], M[i + 1]) << ' ';
	}
}


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

const int maxn = 2e5 + 5;
int dp[maxn], m, pd[maxn], par[maxn], pr[maxn];
vector <int> D[maxn];

bool cmp(int i, int j) {
	return __gcd(j, m) < __gcd(i, m);
}

int varoon(int a, int m) {
//	cout << a << ' ' << m << endl;
	if (a == 1)
		return 1;
//	cout << "H " << m % a << ' ' << a << endl;
	int x = varoon(m % a, a);
	return m - ((1ll * x * (m % a) - 1) / a + m / a * x) % m;
}

int findx(int a, int b) {
	return (varoon(a / __gcd(a, m), m / __gcd(a, m)) * b / __gcd(a, m)) % m;
}

int main() {
	int n;
	cin >> n >> m;
	set <int> S;
	for (int i = 0; i < m; i++) {
		S.insert(i);
		for (int j = i + 1; j <= m; j += i + 1) {
			D[j].push_back(i + 1);
		}
	}
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		S.erase(i);
	}
	vector <int> M;
	for (int i = 0; i < S.size(); i++) {
		M.push_back(i);
	}
	sort(M.begin(), M.end(), cmp);
	fill(pr, pr + maxn, -1);
	for (int id = 0; id < m - n; id++) {
		int i = M[id];
		int x = dp[__gcd(i, m)] + 1;
		pd[i] = x;
		par[i] = pr[__gcd(i, m)];
		for (auto j: D[__gcd(i, m)]) {
			dp[j] = max(dp[j], x);
			if (dp[j] == x)
				pr[j] = i;
		}
	}
	cout << dp[1] << '\n';
	int j = pr[1];
	M.clear();
	M.push_back(1);
	while (~j) {
		M.push_back(j);
//		cout << j << endl;
		j = par[j];
	}
	for (int i = 0; i < (int)M.size() - 1; i++) {
		cout << findx(M[i], M[i + 1]) << ' ';
	}
}


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

const int maxn = 2e5 + 5;
int dp[maxn], m, pd[maxn], par[maxn], pr[maxn];
vector <int> D[maxn];

bool cmp(int i, int j) {
	return __gcd(j, m) < __gcd(i, m);
}

int varoon(int a, int m) {
//	cout << a << ' ' << m << endl;
	if (a == 1)
		return 1;
//	cout << "H " << m % a << ' ' << a << endl;
	int x = varoon(m % a, a);
	return m - ((1ll * x * (m % a) - 1) / a + m / a * x) % m;
}

int findx(int a, int b) {
	return (varoon(a / __gcd(a, m), m / __gcd(a, m)) * b / __gcd(a, m)) % m;
}

int main() {
	int n;
	cin >> n >> m;
	set <int> S;
	for (int i = 0; i < m; i++) {
		S.insert(i);
		for (int j = i + 1; j <= m; j += i + 1) {
			D[j].push_back(i + 1);
		}
	}
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		S.erase(a);
	}
	vector <int> M;
	for (auto i: S) {
		M.push_back(i);
	}
	sort(M.begin(), M.end(), cmp);
	fill(pr, pr + maxn, -1);
	for (int id = 0; id < m - n; id++) {
		int i = M[id];
		int x = dp[__gcd(i, m)] + 1;
		pd[i] = x;
		par[i] = pr[__gcd(i, m)];
		for (auto j: D[__gcd(i, m)]) {
			dp[j] = max(dp[j], x);
			if (dp[j] == x)
				pr[j] = i;
		}
	}
	cout << dp[1] << '\n';
	int j = pr[1];
	M.clear();
	M.push_back(1);
	while (~j) {
		M.push_back(j);
//		cout << j << endl;
		j = par[j];
	}
	for (int i = 0; i < (int)M.size() - 1; i++) {
		cout << findx(M[i], M[i + 1]) << ' ';
	}
}


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

#define int long long
const int maxn = 2e5 + 5;
int dp[maxn], m, pd[maxn], par[maxn], pr[maxn];
vector <int> D[maxn];

bool cmp(int i, int j) {
	return __gcd(j, m) < __gcd(i, m);
}

int varoon(int a, int m) {
//	cout << a << ' ' << m << endl;
	if (a == 1)
		return 1;
//	cout << "H " << m % a << ' ' << a << endl;
	int x = varoon(m % a, a);
	return m - (((1ll * x * (m % a) - 1) / a + m / a * x) % m + m) % m;
}

int findx(int a, int b) {
	return ((varoon(a / __gcd(a, m), m / __gcd(a, m)) * b / __gcd(a, m)) % m + m) % m;
}

int32_t main() {
	int n;
	cin >> n >> m;
	set <int> S;
	for (int i = 0; i < m; i++) {
		S.insert(i);
		for (int j = i + 1; j <= m; j += i + 1) {
			D[j].push_back(i + 1);
		}
	}
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		S.erase(a);
	}
	vector <int> M;
	for (auto i: S) {
		M.push_back(i);
	}
	sort(M.begin(), M.end(), cmp);
	fill(pr, pr + maxn, -1);
	for (int id = 0; id < m - n; id++) {
		int i = M[id];
		int x = dp[__gcd(i, m)] + 1;
		pd[i] = x;
		par[i] = pr[__gcd(i, m)];
		for (auto j: D[__gcd(i, m)]) {
			dp[j] = max(dp[j], x);
			if (dp[j] == x)
				pr[j] = i;
		}
	}
	cout << dp[1] << '\n';
	int j = pr[1];
	M.clear();
	M.push_back(1);
	while (~j) {
		M.push_back(j);
//		cout << j << endl;
		j = par[j];
	}
	for (int i = 0; i < (int)M.size() - 1; i++) {
		cout << findx(M[i], M[i + 1]) << ' ';
	}
}


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

const int maxn = 2e5 + 5;
int dp[maxn], m, pd[maxn], par[maxn], pr[maxn];
vector <int> D[maxn];

bool cmp(int i, int j) {
	return __gcd(j, m) < __gcd(i, m);
}

int varoon(int a, int m) {
//	cout << a << ' ' << m << endl;
	if (a == 1)
		return 1;
//	cout << "H " << m % a << ' ' << a << endl;
	int x = varoon(m % a, a);
	return m - ((1ll * x * (m % a) - 1) / a + m / a * x) % m;
}

int findx(int a, int b) {
	return (varoon(a / __gcd(a, m), m / __gcd(a, m)) * b / __gcd(a, m)) % m;
}

int main() {
	int n;
	cin >> n >> m;
	set <int> S;
	for (int i = 0; i < m; i++) {
		S.insert(i);
		for (int j = i + 1; j <= m; j += i + 1) {
			D[j].push_back(i + 1);
		}
	}
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		S.erase(i);
	}
	vector <int> M;
	for (auto i: S) {
		M.push_back(i);
	}
	sort(M.begin(), M.end(), cmp);
	fill(pr, pr + maxn, -1);
	for (int id = 0; id < m - n; id++) {
		int i = M[id];
		int x = dp[__gcd(i, m)] + 1;
		pd[i] = x;
		par[i] = pr[__gcd(i, m)];
		for (auto j: D[__gcd(i, m)]) {
			dp[j] = max(dp[j], x);
			if (dp[j] == x)
				pr[j] = i;
		}
	}
	cout << dp[1] << '\n';
	int j = pr[1];
	M.clear();
	M.push_back(1);
	while (~j) {
		M.push_back(j);
//		cout << j << endl;
		j = par[j];
	}
	for (int i = 0; i < (int)M.size() - 1; i++) {
		cout << findx(M[i], M[i + 1]) << ' ';
	}
}


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

#define int long long
const int maxn = 2e5 + 5;
int dp[maxn], m, pd[maxn], par[maxn], pr[maxn];
vector <int> D[maxn];

bool cmp(int i, int j) {
	return __gcd(j, m) < __gcd(i, m);
}

int varoon(int a, int m) {
//	cout << a << ' ' << m << endl;
	if (a == 1)
		return 1;
//	cout << "H " << m % a << ' ' << a << endl;
	int x = varoon(m % a, a);
	return m - (((1ll * x * (m % a) - 1) / a + m / a * x) % m + m) % m;
}

int findx(int a, int b) {
	return ((varoon(a / __gcd(a, m), m / __gcd(a, m)) * b / __gcd(a, m)) % m + m) % m;
}

int main() {
	int n;
	cin >> n >> m;
	set <int> S;
	for (int i = 0; i < m; i++) {
		S.insert(i);
		for (int j = i + 1; j <= m; j += i + 1) {
			D[j].push_back(i + 1);
		}
	}
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		S.erase(a);
	}
	vector <int> M;
	for (auto i: S) {
		M.push_back(i);
	}
	sort(M.begin(), M.end(), cmp);
	fill(pr, pr + maxn, -1);
	for (int id = 0; id < m - n; id++) {
		int i = M[id];
		int x = dp[__gcd(i, m)] + 1;
		pd[i] = x;
		par[i] = pr[__gcd(i, m)];
		for (auto j: D[__gcd(i, m)]) {
			dp[j] = max(dp[j], x);
			if (dp[j] == x)
				pr[j] = i;
		}
	}
	cout << dp[1] << '\n';
	int j = pr[1];
	M.clear();
	M.push_back(1);
	while (~j) {
		M.push_back(j);
//		cout << j << endl;
		j = par[j];
	}
	for (int i = 0; i < (int)M.size() - 1; i++) {
		cout << findx(M[i], M[i + 1]) << ' ';
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
#define int ll
typedef pair<ll, ll> ii;
typedef pair<ii, ii> iii;
ll MOD = 1e9 + 7;
const ld E = 1e-5;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#ifndef M_PI
#define M_PI 3.141592653589793238462643383
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
	putchar(' ');
}

#ifdef LOCAL
//#define DEBUG
#endif

#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

const int MAX = 2e5 + 10;

int dp[MAX];
int has[MAX];

bool used[MAX];
int from[MAX];

vector<int> vec[MAX];

ll _pow(ll a, ll b, ll m){
	return (b == 0 ? 1 : b & 1 ? a * _pow(a, b - 1, m) : sqr(_pow(a, b >> 1, m))) % m;
}
//x * y == z
// a = z
// b = x

//7 * y = 3
//y = 3

int gcd (int a, int b, int & x, int & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	int x1, y1;
	int d = gcd (b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}

int get(int a, int m){
	int x, y;
	//cout << a << " " << m << endl;
	int g = gcd(a, m, x, y);
	if (g != 1)
		assert(false);
	else {
		x = (x % m + m) % m;
		//cout << "! " << x << endl;
		return x;
	}
}

int solve(int a, int b, int m){
	int B = b;
	int M = m;
	int w = __gcd(B, M);
	int g = get(b / w, m / w);
	assert(a % w == 0);
	g *= a / w;
	g %= m;
	if((b * g) % m != a){
		assert(false);
		cout << "error " << a << " " << b << " " << m << " " << g << endl;
	}
	return g;
}

#undef int
int main() {
#define int ll
	sync;
	srand(time(NULL));
	cout.precision(12);
	cout << fixed;
#ifdef LOCAL
	input;
#else

#endif

	int n, m;
	cin >> n >> m;

	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		used[a] = true;
	}

	if(m == 1){
		vector<int> ans;
		for(int i = 0; i >= 0; i--){
			if(!used[i]){
				ans.push_back(i);
			}
		}
		cout << ans.size() << endl;
		for(int a : ans){
			cout << a << " ";
		}
		cout << endl;
		return 0;
	}

	for(int i = 1; i < m; i++) {
		if(!used[i]) {
			has[__gcd(i, m)]++;
			dp[__gcd(i, m)]++;
			vec[__gcd(i, m)].push_back(i);
		}
	}

	int t = m;

	vector<int> q;

	for(int i = 2; i <= t; i++) {
		if(t % i == 0) {
			while(t % i == 0) {
				t /= i;
			}
			q.push_back(i);
		}
	}

	int ans = 0;
	int pos = 0;

	for(int i = 1; i < m; i++) {
		if(dp[i]) {
			for(int a : q){
				if(m % (1LL * a * i) == 0 && dp[i] + has[a * i] > dp[a * i]){
					dp[a * i] = dp[i] + has[a * i];
					from[a * i] = i;
				}
			}
			if(dp[i] > ans){
				ans = dp[i];
				pos = i;
			}
		}
	}

	vector<int> v;

	while(pos){
		for(int a : vec[pos]){
			v.push_back(a);
		}
		pos = from[pos];
	}

	reverse(v.begin(), v.end());

#ifdef LOCAL
	for(int a : v){
		cout << a << " ";
	}
	cout << endl;
#endif

	for(int i = (int) v.size() - 1; i > 0; i--){
		v[i] = solve(v[i], v[i - 1], m);
	}

	if(!used[0]){
		v.push_back(0);
	}

	cout << v.size() << endl;
	for(int a : v){
		cout << a << " ";
	}
	cout << endl;

#ifdef LOCAL
	int s = 1;
	for(int a : v){
		s *= a;
		s %= m;
		cout << s << " ";
	}
	cout << endl;
#endif
	//todo 0
	//todo test m = 2
	//todo test with only one element

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
#define int ll
typedef pair<ll, ll> ii;
typedef pair<ii, ii> iii;
ll MOD = 1e9 + 7;
const ld E = 1e-5;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#ifndef M_PI
#define M_PI 3.141592653589793238462643383
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
	putchar(' ');
}

#ifdef LOCAL
//#define DEBUG
#endif

#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

const int MAX = 2e5 + 10;

int dp[MAX];
int has[MAX];

bool used[MAX];
int from[MAX];

vector<int> vec[MAX];

ll _pow(ll a, ll b, ll m){
	return (b == 0 ? 1 : b & 1 ? a * _pow(a, b - 1, m) : sqr(_pow(a, b >> 1, m))) % m;
}
//x * y == z
// a = z
// b = x

//7 * y = 3
//y = 3

int gcd (int a, int b, int & x, int & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	int x1, y1;
	int d = gcd (b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}

int get(int a, int m){
	int x, y;
	//cout << a << " " << m << endl;
	int g = gcd(a, m, x, y);
	if (g != 1)
		cout << "no solution";
	else {
		x = (x % m + m) % m;
		//cout << "! " << x << endl;
		return x;
	}
}

int solve(int a, int b, int m){
	int B = b;
	int M = m;
	int w = __gcd(B, M);
	int g = get(b / w, m / w);
	g *= a / w;
	g %= m;
	if((b * g) % m != a){
		assert(false);
		cout << "error " << a << " " << b << " " << m << " " << g << endl;
	}
	return g;
}

#undef int
int main() {
#define int ll
	sync;
	srand(time(NULL));
	cout.precision(12);
	cout << fixed;
#ifdef LOCAL
	input;
#else

#endif

	int n, m;
	cin >> n >> m;

	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		used[a] = true;
	}

	if(m == 1){
		vector<int> ans;
		for(int i = 1; i >= 0; i--){
			if(!used[i]){
				ans.push_back(i);
			}
		}
		cout << ans.size() << endl;
		for(int a : ans){
			cout << a << " ";
		}
		cout << endl;
		return 0;
	}

	for(int i = 1; i < m; i++) {
		if(!used[i]) {
			has[__gcd(i, m)]++;
			dp[__gcd(i, m)]++;
			vec[__gcd(i, m)].push_back(i);
		}
	}

	int t = m;

	vector<int> q;

	for(int i = 2; i <= t; i++) {
		if(t % i == 0) {
			while(t % i == 0) {
				t /= i;
			}
			q.push_back(i);
		}
	}

	int ans = 0;
	int pos = 0;

	for(int i = 1; i < m; i++) {
		if(dp[i]) {
			for(int a : q){
				if(m % (1LL * a * i) == 0 && dp[i] + has[a * i] > dp[a * i]){
					dp[a * i] = dp[i] + has[a * i];
					from[a * i] = i;
				}
			}
			if(dp[i] > ans){
				ans = dp[i];
				pos = i;
			}
		}
	}

	vector<int> v;

	while(pos){
		for(int a : vec[pos]){
			v.push_back(a);
		}
		pos = from[pos];
	}

	reverse(v.begin(), v.end());

#ifdef LOCAL
	for(int a : v){
		cout << a << " ";
	}
	cout << endl;
#endif

	for(int i = (int) v.size() - 1; i > 0; i--){
		v[i] = solve(v[i], v[i - 1], m);
	}

	if(!used[0]){
		v.push_back(0);
	}

	cout << v.size() << endl;
	for(int a : v){
		cout << a << " ";
	}
	cout << endl;

#ifdef LOCAL
	int s = 1;
	for(int a : v){
		s *= a;
		s %= m;
		cout << s << " ";
	}
	cout << endl;
#endif
	//todo 0
	//todo test m = 2
	//todo test with only one element

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
#define int ll
typedef pair<ll, ll> ii;
typedef pair<ii, ii> iii;
ll MOD = 1e9 + 7;
const ld E = 1e-5;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#ifndef M_PI
#define M_PI 3.141592653589793238462643383
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
	putchar(' ');
}

#ifdef LOCAL
//#define DEBUG
#endif

#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

const int MAX = 2e5 + 10;

int dp[MAX];
int has[MAX];

bool used[MAX];
int from[MAX];

vector<int> vec[MAX];

ll _pow(ll a, ll b, ll m){
	return (b == 0 ? 1 : b & 1 ? a * _pow(a, b - 1, m) : sqr(_pow(a, b >> 1, m))) % m;
}
//x * y == z
// a = z
// b = x

//7 * y = 3
//y = 3

int gcd (int a, int b, int & x, int & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	int x1, y1;
	int d = gcd (b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}

int get(int a, int m){
	int x, y;
	//cout << a << " " << m << endl;
	int g = gcd(a, m, x, y);
	if (g != 1)
		assert(false);
	else {
		x = (x % m + m) % m;
		//cout << "! " << x << endl;
		return x;
	}
}

int solve(int a, int b, int m){
	int B = b;
	int M = m;
	int w = __gcd(B, M);
	int g = get(b / w, m / w);
	g *= a / w;
	g %= m;
	if((b * g) % m != a){
		assert(false);
		cout << "error " << a << " " << b << " " << m << " " << g << endl;
	}
	return g;
}

#undef int
int main() {
#define int ll
	sync;
	srand(time(NULL));
	cout.precision(12);
	cout << fixed;
#ifdef LOCAL
	input;
#else

#endif

	int n, m;
	cin >> n >> m;

	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		used[a] = true;
	}

	if(m == 1){
		vector<int> ans;
		for(int i = 1; i >= 0; i--){
			if(!used[i]){
				ans.push_back(i);
			}
		}
		cout << ans.size() << endl;
		for(int a : ans){
			cout << a << " ";
		}
		cout << endl;
		return 0;
	}

	for(int i = 1; i < m; i++) {
		if(!used[i]) {
			has[__gcd(i, m)]++;
			dp[__gcd(i, m)]++;
			vec[__gcd(i, m)].push_back(i);
		}
	}

	int t = m;

	vector<int> q;

	for(int i = 2; i <= t; i++) {
		if(t % i == 0) {
			while(t % i == 0) {
				t /= i;
			}
			q.push_back(i);
		}
	}

	int ans = 0;
	int pos = 0;

	for(int i = 1; i < m; i++) {
		if(dp[i]) {
			for(int a : q){
				if(m % (1LL * a * i) == 0 && dp[i] + has[a * i] > dp[a * i]){
					dp[a * i] = dp[i] + has[a * i];
					from[a * i] = i;
				}
			}
			if(dp[i] > ans){
				ans = dp[i];
				pos = i;
			}
		}
	}

	vector<int> v;

	while(pos){
		for(int a : vec[pos]){
			v.push_back(a);
		}
		pos = from[pos];
	}

	reverse(v.begin(), v.end());

#ifdef LOCAL
	for(int a : v){
		cout << a << " ";
	}
	cout << endl;
#endif

	for(int i = (int) v.size() - 1; i > 0; i--){
		v[i] = solve(v[i], v[i - 1], m);
	}

	if(!used[0]){
		v.push_back(0);
	}

	cout << v.size() << endl;
	for(int a : v){
		cout << a << " ";
	}
	cout << endl;

#ifdef LOCAL
	int s = 1;
	for(int a : v){
		s *= a;
		s %= m;
		cout << s << " ";
	}
	cout << endl;
#endif
	//todo 0
	//todo test m = 2
	//todo test with only one element

}


#include <bits/stdc++.h>

#define INF 1LL << 30
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl;
#define debug2(x,y) cout << #x << " = " << x << " --- " << #y << " = " << y << "\n";
#define debugM( x, l, c ) { rep( i, 0, l ){ rep( j, 0, c ) cout << x[i][j] << " "; printf("\n");}}
#define all(S) (S).begin(), (S).end()
#define F first
#define S second
#define mk make_pair
#define N 25000
#define FOR(i,a,b) rep(i,a,b+1)
#define SET(c,v) memset(c, v, sizeof c);

using namespace std;

typedef long long int ll;
typedef pair <ll, ll> ii;

ll fastExp( ll b, ll e, ll mod ){
	ll ans = 1;
	while( e ){
		if( e&1 ) ans = ( ans * b )%mod;
		b = ( b * b )%mod;
		e >>= 1;
	}
	return ans;
}

int n, m, cant[200200];
vector<int> ans, v[200200];
int nxt[200200], g[200200];

ll extend_gcd(ll a, ll b, ll &x, ll &y) {
	if( b == 0 ){
		x = 1; y = 0;
		return a;
	}
	else{
		ll r = extend_gcd(b, a % b, y, x);
		y -= x * (a / b);
		return r;
	}
}

void dfs( int u, int last ){

	if( !u ) return;
	rep( i, 0, v[u].size() ){
		ll x, y;
		int k = extend_gcd( last, m, x, y );
		int aux = ((x*v[u][i]/k)%(m/k) + m/k )%m;
		ans.pb(aux);
		last = v[u][i];
	}

	dfs( nxt[u], last );
}

int main(){

	while( scanf("%d%d", &n, &m ) != EOF ){
		rep( i, 0, n ){
			int x;
			scanf("%d", &x );
			cant[x] = 1;
		}
		rep( i, 1, m ){
			if( cant[i] ) continue;
			int k = __gcd(i, m);
			v[k].pb(i);
		}
		int best = 0, id = 0;
		for( int i = m-1; i > 0; i-- ){
			g[i] = 0;
			for( int j = i+i; j < m; j += i ){
				if( g[j] > g[i] ){
					g[i] = g[j];
					nxt[i] = j;
				}
			}
			g[i] += v[i].size();
			if( g[i] > best ){
				best = g[i];
				id = i;
			}
		}
		dfs( id, 1 );
		if( !cant[0] ) ans.pb(0);
		printf("%d\n", ans.size() );
		rep( i, 0, ans.size() ) printf("%d%c", ans[i], i+1 == ans.size() ? '\n':' ' );
	}
}


#include <bits/stdc++.h>

#define INF 1LL << 30
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl;
#define debug2(x,y) cout << #x << " = " << x << " --- " << #y << " = " << y << "\n";
#define debugM( x, l, c ) { rep( i, 0, l ){ rep( j, 0, c ) cout << x[i][j] << " "; printf("\n");}}
#define all(S) (S).begin(), (S).end()
#define F first
#define S second
#define mk make_pair
#define N 25000
#define FOR(i,a,b) rep(i,a,b+1)
#define SET(c,v) memset(c, v, sizeof c);

using namespace std;

typedef long long int ll;
typedef pair <ll, ll> ii;

ll fastExp( ll b, ll e, ll mod ){
	ll ans = 1;
	while( e ){
		if( e&1 ) ans = ( ans * b )%mod;
		b = ( b * b )%mod;
		e >>= 1;
	}
	return ans;
}

int n, m, cant[200200];
vector<int> ans, v[200200];
int nxt[200200], g[200200];

ll extend_gcd(ll a, ll b, ll &x, ll &y) {
	if( b == 0 ){
		x = 1; y = 0;
		return a;
	}
	else{
		ll r = extend_gcd(b, a % b, y, x);
		y -= x * (a / b);
		return r;
	}
}

void dfs( int u, int last ){

	if( !u ) return;
	rep( i, 0, v[u].size() ){
		ll x, y;
		int k = extend_gcd( last, m, x, y );
		int aux = ((x*v[u][i]/k)%(m/k) + m/k )%m;
		ans.pb(aux);
		last = v[u][i];
	}

	dfs( nxt[u], last );
}

int main(){

	while( scanf("%d%d", &n, &m ) != EOF ){
		rep( i, 0, n ){
			int x;
			scanf("%d", &x );
			cant[x] = 1;
		}
		rep( i, 1, m ){
			if( cant[i] ) continue;
			int k = __gcd(i, m);
			v[k].pb(i);
		}
		int best = 0, id;
		for( int i = m-1; i > 0; i-- ){
			g[i] = 0;
			for( int j = i+i; j < m; j += i ){
				if( g[j] > g[i] ){
					g[i] = g[j];
					nxt[i] = j;
				}
			}
			g[i] += v[i].size();
			if( g[i] > best ){
				best = g[i];
				id = i;
			}
		}
		dfs( id, 1 );
		if( !cant[0] ) ans.pb(0);
		printf("%d\n", ans.size() );
		rep( i, 0, ans.size() ) printf("%d%c", ans[i], i+1 == ans.size() ? '\n':' ' );
	}
}


#include <bits/stdc++.h>

using namespace std;
#define forn(i, n) for (int i = 0; i < n; i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
#define prev previ
#define tm tmmm
#define div divv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const ll mod = ll(1e9) + 7;

int n, m, ok[300000], dp[300000], pr[300000];
vector<int> k[300000], a, div;

void my_gcd(ll x, ll y, ll &a, ll &b) {
	if (x < y) {
		my_gcd(y, x, b, a);
		re;
	}
	if (y == 0) {
		a = 1;
		b = 0;
		re;
	}
	ll na, nb;
	my_gcd(y, x % y, nb, na);
	a = na;
	b = nb - (x / y) * na;
}
int main() {
	//iostream::sync_with_stdio(0);
	//freopen("a.in", "r", stdin);
	scanf("%d%d", &n, &m);
	a.resize(n);
	forn (i, n) {
		cin >> a[i];
		ok[a[i]] = 1;
	}
	forn (i, m) {
		if (ok[i] == 0)
			k[__gcd(i, m)].push_back(i);
	}
	dp[1] = sz(k[1]);
	for (int i = 1; i <= m; i++)
		if (m % i == 0)
			div.push_back(i);
	for (int i = 0; i < sz(div); i++) {
		dp[i] = 0;
		pr[i] = -1;
		forn (j, i)
			if (div[i] % div[j] == 0 && dp[i] < dp[j]) {
				dp[i] = dp[j];
				pr[i] = j;
			}
		dp[i] += sz(k[div[i]]);
	}
	int ans = 0, pos = 0;
	for (int i = 0; i < sz(div); i++)
		if (dp[i] > ans) {
			ans = dp[i];
			pos = i;
		}
	vector<int> an;
	while (pos >= 0) {
		for (int v : k[div[pos]])
			an.push_back(v);
		pos = pr[pos];
	}
	an.push_back(1);
	reverse(an.begin(), an.end());
	printf("%d\n", ans);
	for (int i = 1; i < sz(an); i++) {
		ll a, b;
		my_gcd(an[i - 1], m, a, b);
		a *= (ll(an[i]) / ll(__gcd(an[i - 1], m)));
		a %= m;
		a += ll(m);
		a %= m;
		printf("%d ", int(a));
	}
}


#include <bits/stdc++.h>
using namespace std;
int n, m, f;
int gcd(int a, int b)
{
    if(b==0) return a;
    else return gcd(b, a%b);
}
int pow(int x, int y)
{
    if(y==0) return 1%m;
    if(y%2) return (1ll*pow(x, y-1)*x)%m;
    else
    {
        int va=pow(x, y/2);
        return (1ll*va*va)%m;
    }
}
int main()
{
    //freopen("input.txt", "r", stdin);
    cin>>n>>m;
    for(int a=1; a<=m; a++) if(gcd(a, m)==1) f++;
    int us[m];
    for(int a=0; a<m; a++) us[a]=0;
    for(int a=0; a<n; a++)
    {
        int x;
        scanf("%d", &x);
        us[x]=1;
    }
    vector <int> ch[m], div;
    for(int a=1; a<m; a++) if(us[a]==0) ch[gcd(a, m)].push_back(a);
    int dp[m], q[m], pr[m];
    for(int a=0; a<m; a++)
    {
        pr[a]=-1;
        dp[a]=ch[a].size();
        q[a]=dp[a];
        if(dp[a]!=0) div.push_back(a);
    }
    for(int a=1; a<m; a++)
    {
        if(dp[a]!=0)
        {
            for(int b=0; b<div.size(); b++)
            {
                if(div[b]%a==0 and div[b]>a)
                {
                    if(dp[div[b]]<dp[a]+q[div[b]])
                    {
                        dp[div[b]]=dp[a]+q[div[b]];
                        pr[div[b]]=a;
                    }
                }
            }
        }
    }
    int cu, best=-1;
    for(int a=1; a<m; a++)
    {
        if(dp[a]>best)
        {
            best=dp[a], cu=a;
        }
    }
    vector <int> pref;
    while(cu!=-1)
    {
        for(int a=0; a<ch[cu].size(); a++) pref.push_back(ch[cu][a]);
        cu=pr[cu];
    }
    reverse(pref.begin(), pref.end());
    if(us[0]==0) pref.push_back(0);
    cout<<pref.size()<<"\n";
    for(int a=0; a<pref.size(); a++)
    {
        if(a==0) printf("%d ", pref[0]);
        else
        {
            int d=gcd(pref[a-1], m);
            int x=pref[a-1]/d, y=pref[a]/d, z=m/d;
            printf("%d ", (1ll*y*pow(x, f-1))%m);
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
int n, m, f=0;
int gcd(int a, int b)
{
    if(b==0) return a;
    else return gcd(b, a%b);
}
int pow(int x, int y)
{
    if(y==0) return 1%m;
    if(y%2) return (1ll*pow(x, y-1)*x)%m;
    else
    {
        int va=pow(x, y/2);
        return (1ll*va*va)%m;
    }
}
int main()
{
    //freopen("input.txt", "r", stdin);
    cin>>n>>m;
    for(int a=1; a<=m; a++) if(gcd(a, m)==1) f++;
    int us[m];
    for(int a=0; a<m; a++) us[a]=0;
    for(int a=0; a<n; a++)
    {
        int x;
        scanf("%d", &x);
        us[x]=1;
    }
    vector <int> ch[m], div;
    for(int a=1; a<m; a++) if(us[a]==0) ch[gcd(a, m)].push_back(a);
    int dp[m], q[m], pr[m];
    for(int a=0; a<m; a++)
    {
        pr[a]=-1;
        dp[a]=ch[a].size();
        q[a]=dp[a];
        if(dp[a]!=0) div.push_back(a);
    }
    for(int a=1; a<m; a++)
    {
        if(dp[a]!=0)
        {
            for(int b=0; b<div.size(); b++)
            {
                if(div[b]%a==0 and div[b]>a)
                {
                    if(dp[div[b]]<dp[a]+q[div[b]])
                    {
                        dp[div[b]]=dp[a]+q[div[b]];
                        pr[div[b]]=a;
                    }
                }
            }
        }
    }
    int cu=-1, best=-1;
    for(int a=1; a<m; a++)
    {
        if(dp[a]>best)
        {
            best=dp[a], cu=a;
        }
    }
    vector <int> pref;
    while(cu!=-1)
    {
        for(int a=0; a<ch[cu].size(); a++) pref.push_back(ch[cu][a]);
        cu=pr[cu];
    }
    reverse(pref.begin(), pref.end());
    if(us[0]==0) pref.push_back(0);
    cout<<pref.size()<<"\n";
    for(int a=0; a<pref.size(); a++)
    {
        if(a==0) printf("%d ", pref[0]);
        else
        {
            int d=gcd(pref[a-1], m);
            int x=pref[a-1]/d, y=pref[a]/d, z=m/d;
            printf("%d ", (1ll*y*pow(x, f-1))%m);
        }
    }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans,v[1000001],a[1000001],sz[1000001],f[1000001],nt[1000001];
vector<ll>zh[200001];
ll gcd(ll x,ll y){
	if(!y)return x;
	return gcd(y,x%y);
}
ll exgcd(ll a,ll b,ll &x,ll &y){
	if(!b){
		x=1;y=0;
		return a;
	}
	ll t,hh=exgcd(b,a%b,x,y);
	t=x;x=y;y=t-a/b*y;
	return hh;
}
ll work(ll aa,ll bb){
	ll x,y,hh=exgcd(aa,m,x,y);
	x=((x+m)%m*bb/hh)%m;
	return x;
}
void get(ll x,ll la){
	ll i;
	for(i=0;i<zh[x].size();i++){
		ans=work(la,zh[x][i]);
		printf("%lld ",ans);
		la=zh[x][i];
	}
	if(nt[x])get(nt[x],la);
}
int main(){
	ll i,j,x;
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%lld",&x);
		v[x]=1;
	}
	for(i=1;i<m;i++)if(!v[i]){
		x=gcd(i,m);
		sz[x]++;
		zh[x].push_back(i);
	}
	for(i=m/2;i;i--)if(sz[i]){
		for(j=i*2;j<=m;j+=i)if(f[j]&&f[j]>f[i]){
			f[i]=f[j];
			nt[i]=j;
		}
		f[i]+=sz[i];
	}
	ans=f[1];
	if(!v[0])ans++;
	printf("%lld\n",ans);
	get(1,1);
	if(!v[0])puts("0");
//
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans,v[1000001],a[1000001],sz[1000001],f[1000001],nt[1000001];
vector<ll>zh[200001];
ll gcd(ll x,ll y){
	if(!y)return x;
	return gcd(y,x%y);
}
ll exgcd(ll a,ll b,ll &x,ll &y){
	if(!b){
		x=1;y=0;
		return a;
	}
	ll t,hh=exgcd(b,a%b,x,y);
	t=x;x=y;y=t-a/b*y;
	return hh;
}
ll work(ll aa,ll bb){
	ll x,y,hh=exgcd(aa,m,x,y);
	x=((x+m)%m*bb/hh)%m;
	return x;
}
void get(ll x,ll la){
	ll i;
	for(i=0;i<zh[x].size();i++){
		ans=work(la,zh[x][i]);
		printf("%lld ",ans);
		la=zh[x][i];
	}
	if(nt[x])get(nt[x],la);
}
int main(){
	ll i,j,x;
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%lld",&x);
		v[x]=1;
	}
	for(i=1;i<m;i++)if(!v[i]){
		x=gcd(i,m);
		sz[x]++;
		zh[x].push_back(i);
	}
	for(i=m/2;i;i--)if(sz[i]){
		for(j=i*2;j<=m;j+=i)if(f[j]&&f[j]>f[i]){
			f[i]=f[j];
			nt[i]=j;
		}
		f[i]+=sz[i];
	}
	ans=f[1];
	if(!v[0])ans++;
	printf("%lld\n",ans);
	get(1,1);
	if(!v[0])puts("0");
}


using System;
using System.IO;
using System.Text;

namespace To_Add_or_Not_to_Add
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();
            int k = Next();

            var nn = new int[n + 1];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }
            nn[n] = int.MaxValue;
            Array.Sort(nn);

            int max = 0;
            int nnn = -1;

            var sums = new long[n + 1];
            for (int i = 0; i < n; i++)
            {
                sums[i + 1] = sums[i] + nn[i];

                if (nn[i] != nn[i + 1])
                {
                    int l = 0;
                    int r = i + 1;
                    while (l < r)
                    {
                        int m = (l + r)/2;
                        long count = i - m + 1;

                        if (count*nn[i] - (sums[i + 1] - sums[m]) <= k)
                            r = m;
                        else l = m + 1;
                    }

                    if (i - l + 1 > max)
                    {
                        max = i - l + 1;
                        nnn = nn[i];
                    }
                }
            }

            writer.Write(max);
            writer.Write(' ');
            writer.WriteLine(nnn);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int m = 1;
            do
            {
                c = reader.Read();
                if (c == '-')
                    m = -1;
            } while (c < '0' || c > '9');
            int res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return m*res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _143c
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var d1 = Console.ReadLine().Split(' ').Select(di => long.Parse(di)).ToArray();
            long n = d1[0];
            long k = d1[1];

            var a = Console.ReadLine().Split(' ').Select(di => long.Parse(di)).ToArray();
            Array.Sort(a);

            var sums = new long[n];
            sums[0] = a[0];
            for (int i = 1; i < n; i++)
            {
                sums[i] = sums[i - 1] + a[i];
            }

            long cur = a[n - 1];
            long gmax = 0;
            long max = 0;
            long minn = cur;
            for (long i = n - 1; i >= 0; i--)
            {
                var next = a[i];
                if (next == cur)
                {
                    max++;

                    continue;
                }

                long li = i + 1;

                long l = 0;
                long r = li;
                long csum = sums[i];

                while (true)
                {
                    if (r == l)
                    {
                        break;
                    }

                    var m = l + (r - l) / 2;

                    var s1 = sums[m];
                    var ts = csum - s1;
                    //ts -= next;
                    ts += a[m];

                    var count = li - m;
                    var need = cur * count;
                    var tosum = need - ts;

                    if (tosum > k)
                    {
                        l = m + 1;
                    }
                    else
                    {
                        r = m;
                    }
                }

                long ac = li - l;
                long newm = max + ac;
                if (newm >= gmax)
                {
                    gmax = newm;
                    minn = cur;
                }

                cur = next;
                max = 1;
            }

            if (max >= gmax)
            {
                gmax = max;
                minn = cur;
            }

            Console.WriteLine("{0} {1}", gmax, minn);

        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _143c
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetIn(File.OpenText("in.txt"));
            var d1 = Console.ReadLine().Split(' ').Select(di => int.Parse(di)).ToArray();
            var n = d1[0];
            var k = d1[1];

            var a = Console.ReadLine().Split(' ').Select(di => int.Parse(di)).ToArray();
            Array.Sort(a);

            var sums = new int[n];
            sums[0] = a[0];
            for (int i = 1; i < n; i++)
            {
                sums[i] = sums[i - 1] + sums[i];
            }

            var cur = a[n - 1];
            var gmax = 1;
            var max = 0;
            var minn = 0;
            for (int i = n - 1; i >= 0; i--)
            {
                var next = a[i];
                if (next == cur)
                {
                    max++;
                    continue;
                }

                var li = i + 1;

                var l = 0;
                var r = li;
                var csum = sums[i];

                while (true)
                {
                    if (r == l)
                    {
                        break;
                    }

                    var m = l + (r - l) / 2;

                    var s1 = sums[m];
                    var ts = csum - s1;
                    //ts -= next;
                    ts += a[m];

                    var count = li - m;
                    var need = next * count;
                    var tosum = need - ts;

                    if (tosum > k)
                    {
                        l = m + 1;
                    }
                    else
                    {
                        r = m;
                    }
                }

                var ac = li - l;
                var newm = max + ac;
                if (newm >= gmax)
                {
                    gmax = newm;
                    minn = cur;
                }

                cur = next;
            }

            Console.WriteLine("{0} {1}", gmax, minn);

        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _143c
{
	class Program
	{
		static void Main(string[] args)
		{
			//Console.SetIn(File.OpenText("in.txt"));
			var d1 = Console.ReadLine().Split(' ').Select(di => int.Parse(di)).ToArray();
			var n = d1[0];
			var k = d1[1];

			var a = Console.ReadLine().Split(' ').Select(di => int.Parse(di)).ToArray();
			Array.Sort(a);

			var sums = new int[n];
			sums[0] = a[0];
			for (int i = 1; i < n; i++)
			{
				sums[i] = sums[i - 1] + a[i];
			}

			var cur = a[n - 1];
			var gmax = 0;
			var max = 0;
			var minn = cur;
			for (int i = n - 1; i >= 0; i--)
			{
				var next = a[i];
				if (next == cur)
				{
					max++;

					continue;
				}

				var li = i + 1;

				var l = 0;
				var r = li;
				var csum = sums[i];

				while (true)
				{
					if (r == l)
					{
						break;
					}

					var m = l + (r - l) / 2;

					var s1 = sums[m];
					var ts = csum - s1;
					//ts -= next;
					ts += a[m];

					var count = li - m;
					var need = cur * count;
					var tosum = need - ts;

					if (tosum > k)
					{
						l = m + 1;
					}
					else
					{
						r = m;
					}
				}

				var ac = li - l;
				var newm = max + ac;
				if (newm >= gmax)
				{
					gmax = newm;
					minn = cur;
				}

				cur = next;
				max = 1;
			}

			if (max >= gmax)
			{
				gmax = max;
				minn = cur;
			}

			Console.WriteLine("{0} {1}", gmax, minn);
		}
	}
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _143c
{
	class Program
	{
		static void Main(string[] args)
		{
			//Console.SetIn(File.OpenText("in.txt"));
			var d1 = Console.ReadLine().Split(' ').Select(di => int.Parse(di)).ToArray();
			var n = d1[0];
			var k = d1[1];

			var a = Console.ReadLine().Split(' ').Select(di => int.Parse(di)).ToArray();
			Array.Sort(a);

			var sums = new int[n];
			sums[0] = a[0];
			for (int i = 1; i < n; i++)
			{
				sums[i] = sums[i - 1] + a[i];
			}

			var cur = a[n - 1];
			var gmax = 0;
			var max = 0;
			var minn = cur;
			for (int i = n - 1; i >= 0; i--)
			{
				var next = a[i];
				if (next == cur)
				{
					max++;

					continue;
				}

				var li = i + 1;

				var l = 0;
				var r = li;
				var csum = sums[i];

				while (true)
				{
					if (r == l)
					{
						break;
					}

					var m = l + (r - l) / 2;

					var s1 = sums[m];
					var ts = csum - s1;
					//ts -= next;
					ts += a[m];

					var count = li - m;
					var need = cur * count;
					var tosum = need - ts;

					if (tosum > k)
					{
						l = m + 1;
					}
					else
					{
						r = m;
					}
				}

				var ac = li - l;
				var newm = max + ac;
				if (newm >= gmax)
				{
					gmax = newm;
					minn = cur;
				}

				cur = next;
			}

			if (cur == a[n - 1])
			{
				gmax = max;
			}

			Console.WriteLine("{0} {1}", gmax, minn);
		}
	}
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var data = Console.ReadLine().Split().Select(d => int.Parse(d)).ToArray();
            var n = data[0];
            var k = data[1];

            //var counts = new int[100000];
            //var sums = new long[100000];
            //var ks = new long[100000];
            data = Console.ReadLine().Split().Select(d => int.Parse(d)).ToArray();
            Array.Sort(data);

            var maxCount = 0;
            var maxVal = 0;
            for (int i = 0; i < n; i++)
            {
                var val = data[i];
                var rem = k;
                var count = 1;
                for (int j = i - 1; j >= 0; j--)
                {
                    var curr = data[j];
                    var diff = val - curr;
                    if (diff <= rem)
                    {
                        count++;
                        rem -= diff;
                    }
                    else
                    {
                        break;
                    }
                }

                if (maxCount < count)
                {
                    maxCount = count;
                    maxVal = val;
                }
            }

            Console.WriteLine(maxCount + " " + maxVal);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    const double EPS = 1e-7;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        return (b != 0) ? gcd(b, a % b) : a;
    }
    static void swap(ref int a, ref int b)
    {
        int t = a;
        a = b;
        b = t;
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) == 1)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _a()
    {

    }
    static void _b()
    {

    }
    static void _c()
    {
        string[] nk = reader.ReadLine().Split();
        long n = long.Parse(nk[0]), k = long.Parse(nk[1]);
        long[] a = new long[n], sum = new long[n];
        string[] sa = reader.ReadLine().Split();
        for (int i = 0; i < n; ++i)
            a[i] = long.Parse(sa[i]);
        Array.Sort(a);
        sum[0] = a[0];
        for (int i = 1; i < n; ++i)
            sum[i] = a[i] + sum[i - 1];
        long count = 0, number = -1;
        for (int i = 1; i < n; ++i)
        {
            long l = 0, r = i;
            while (l < r)
            {
                long c = (l + r) / 2, s = sum[i - 1] - sum[i - c - 1];
                if (c * a[i] - s < k)
                    l = c + 1;
                else
                    r = c;
            }
            long snew = sum[i - 1];
            if (i - l - 1 >= 0)
                snew -= sum[i - l - 1];
            if (l * a[i] - snew <= k)
                if (l + 1 > count)
                {
                    count = l + 1;
                    number = a[i];
                }
        }
        writer.Write("{0} {1}", count, number);
    }
    static void _d()
    {

    }
    static void Main(string[] args)
    {
        _c();
        reader.Close();
        writer.Close();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    const double EPS = 1e-7;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        return (b != 0) ? gcd(b, a % b) : a;
    }
    static void swap(ref int a, ref int b)
    {
        int t = a;
        a = b;
        b = t;
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) == 1)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _a()
    {

    }
    static void _b()
    {

    }
    static void _c()
    {
        string[] nk = reader.ReadLine().Split();
        long n = long.Parse(nk[0]), k = long.Parse(nk[1]);
        long[] a = new long[n];
        string[] sa = reader.ReadLine().Split();
        for (int i = 0; i < n; ++i)
            a[i] = long.Parse(sa[i]);
        Array.Sort(a);
        long count = 1, number = a[0];
        if (k == 0)
        {
            for (int i = 1, c = 1; i < n; ++i)
            {
                if (a[i] == a[i - 1])
                    ++c;
                else if (c > count)
                {
                    count = c;
                    number = a[i - 1];
                }
            }
        }
        else
        {
            long[] sum = new long[n];
            sum[0] = a[0];
            for (int i = 1; i < n; ++i)
                sum[i] = a[i] + sum[i - 1];
            for (int i = 1; i < n; ++i)
            {
                long l = 0, r = i;
                while (l < r)
                {
                    long c = (l + r) / 2, s = sum[i - 1] - sum[i - c - 1];
                    if (c * a[i] - s < k)
                        l = c + 1;
                    else
                        r = c;
                }
                long snew = sum[i - 1];
                if (i - l - 1 >= 0)
                    snew -= sum[i - l - 1];
                if (l * a[i] - snew <= k)
                    if (l + 1 > count)
                    {
                        count = l + 1;
                        number = a[i];
                    }
            }
        }
        writer.Write("{0} {1}", count, number);
    }
    static void _d()
    {

    }
    static void Main(string[] args)
    {
        _c();
        reader.Close();
        writer.Close();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    const double EPS = 1e-7;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        return (b != 0) ? gcd(b, a % b) : a;
    }
    static void swap(ref int a, ref int b)
    {
        int t = a;
        a = b;
        b = t;
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) == 1)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _a()
    {

    }
    static void _b()
    {

    }
    static void _c()
    {
        string[] nk = reader.ReadLine().Split();
        long n = long.Parse(nk[0]), k = long.Parse(nk[1]);
        long[] a = new long[n];
        string[] sa = reader.ReadLine().Split();
        for (int i = 0; i < n; ++i)
            a[i] = long.Parse(sa[i]);
        Array.Sort(a);
        long count = 1, number = a[0];
        if (k == 0)
        {
            for (int i = 1, c = 1; i < n; ++i)
            {
                if (a[i] == a[i - 1])
                    ++c;
                else if (c > count)
                {
                    count = c;
                    number = a[i - 1];
                }
            }
        }
        else
        {
            long d = 0;
            if (a[0] < 0)
            {
                d = a[0];
                for (int i = 0; i < n; ++i)
                    a[i] -= d;
                number = a[0];
            }
            long[] sum = new long[n];
            sum[0] = a[0];
            for (int i = 1; i < n; ++i)
                sum[i] = a[i] + sum[i - 1];
            for (int i = 1; i < n; ++i)
            {
                long l = 0, r = i;
                while (l < r)
                {
                    long c = (l + r) / 2, s = sum[i - 1] - sum[i - c - 1];
                    if (c * a[i] - s < k)
                    {
                        if (c + 1 > count)
                        {
                            count = c + 1;
                            number = a[i];
                        }
                        l = c + 1;
                    }
                    else
                        r = c;
                }
                long snew = sum[i - 1];
                if (i - l - 1 >= 0)
                    snew -= sum[i - l - 1];
                if (l * a[i] - snew <= k)
                    if (l + 1 > count)
                    {
                        count = l + 1;
                        number = a[i];
                    }
            }
            number += d;
        }
        writer.Write("{0} {1}", count, number);
    }
    static void _d()
    {

    }
    static void Main(string[] args)
    {
        _c();
        reader.Close();
        writer.Close();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        void run()
        {
            InputReader cin = new InputReader(Console.OpenStandardInput());
            int n = cin.int32();
            int k = cin.int32();

            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = cin.int32();

            Array.Sort(arr);
            long[] pre = new long[n];
            pre[0] = arr[0];
            for (int i = 1; i < n; i++)
                pre[i] = arr[i] + pre[i - 1];

            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + arr[i]); Console.WriteLine();
            //for (int i = 0; i < n; i++) Console.Write((i == 0 ? "" : " ") + pre[i]); Console.WriteLine();

            int cnt = 1; int res = arr[0];
            for (int j = 1; j < n; j++)
            {
                int s = 0;
                int e = j;
                int a = j;
                while(s <= e) {
                    int m = (s + e) >> 1;
                    long req = (j - m + 1) * arr[j];
                    long val = pre[j] - (m > 0 ? pre[m - 1] : 0);
                    long rem = req - val;
                    if (rem <= k)
                    {
                        a = m;
                        e = m - 1;
                    }
                    else
                    {
                        s = m + 1;
                    }
                }
                int occ = (j - a + 1);
                if (occ > cnt)
                {
                    cnt = occ;
                    res = arr[j];
                }

            }
            Console.WriteLine(cnt + " " + res);

        }

    }

    class InputReader
    {
        Stream inputStream;
        const int bufferSize = 1 << 16;
        int bytesRead;
        int currentBufferTop;
        byte[] buffer;

        public InputReader(Stream _inputStream)
        {
            this.inputStream = _inputStream;
            bytesRead = 0;
            currentBufferTop = 0;
            buffer = new byte[bufferSize];
        }

        public byte peekChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return peekChar();
                }
            }
        }

        public byte readChar()
        {
            if (currentBufferTop < bytesRead)
            {
                return this.buffer[this.currentBufferTop++];
            }
            else
            {
                if (!this.refill())
                {
                    throw new Exception("Error in reading input or reached EOF");
                }
                else
                {
                    return readChar();
                }
            }
        }

        public bool refill()
        {
            currentBufferTop = 0;
            bytesRead = inputStream.Read(buffer, 0, bufferSize);
            return bytesRead > 0;
        }

        public int int32()
        {
            return (int) int64();
        }

        public long int64()
        {
            byte temp = peekChar();
            while (temp != '-' && (temp < '0' || temp > '9'))
            {
                readChar();
                temp = peekChar();
            }
            int sign = 1;
            if (temp == '-') sign = -1;
            if (temp == '-') readChar();
            long readValue = 0;
            temp = peekChar();
            while (temp >= '0' && temp <= '9')
            {
                readValue *= 10;
                readValue += (int)(temp - '0');
                readChar();
                try
                {
                    temp = peekChar();
                }
                catch (Exception e)
                {
                    break;
                }
            }
            return readValue * sign;
        }

        public string token()
        {
            byte temp = peekChar();
            while (isSpace(temp))
            {
                readChar();
                temp = peekChar();
            }

            StringBuilder sb = new StringBuilder();
            sb.Append(temp);
            try
            {
                temp = peekChar();
                while (!isSpace(temp))
                {
                    readChar();
                    temp = peekChar();
                }
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        public string line()
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                byte temp;
                do
                {
                    temp = peekChar();
                    sb.Append(temp);
                    readChar();
                } while (temp != '\n');
            }
            catch (Exception e) { }
            return sb.ToString();
        }

        private bool isSpace(byte t)
        {
            if (t == ' ') return true;
            if (t == '\t') return true;
            if (t == '\r') return true;
            if (t == '\n') return true;
            if (t == '\f') return true;
            return false;
        }
    }
}