#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define inf 0x3f3f3f3f
typedef long long LL;
#define cls(x) memset(x,0,sizeof(x))
#define For(i,j,k) for(register int i=(j);i<=(k);++i)
#define Rep(i,j,k) for(register int i=(j);i>=(k);--i)
#define rint register int
#define il inline

il int read(int x=0,int f=1,char ch='0')
{
    while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return f*x;
}

const int N=1e5+5;
int n,m,v;
int id[N],tot;

int main()
{
    scanf("%d%d%d",&n,&m,&v);

    if(m<n-1 || m>(n-1)*(n-2)/2) return puts("-1"),0;

    int cut=1+(v==1);
    id[1]=cut; id[2]=v; tot=2;
    for(rint i=1;i<=n;++i) if(i!=cut && i!=v) id[++tot]=i;
    for(rint i=2;i<=n;++i)
    {
        printf("%d %d\n",id[i-1],id[i]);
    }

    m-=(n-1);
    for(rint i=2;i<=n&&m;++i)
    {
        for(rint j=i+2;j<=n&&m;++j)
        {
            printf("%d %d\n",id[i],id[j]); --m;
        }
    }
    return 0;
}


#include<stdio.h>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
long long a[100010],b[100010]={0},c[100010]={0},d[100010],e[100010];
long long lcm(long long x,long long y)
{
	long long t;
	t=min(x,y); x=x+y-t;
	while (x%t!=0)
	{
		y=x%t;
		x=t;
		t=y;
	}
	return t;
}
int main()
{
	//char s[110][110],c[110];
	//const double pie=3.1415926535898;
	int n,m,i,j,k,t,s1,v,s,s2,ans;
	long long x;
	//double d,l1,l2,al,be,l,x,y,H,D,h;
	bool t1,t2;
	scanf("%d%d%d",&n,&m,&v);
	x=n*n/2;
	if (x<m || m<n-1) printf("-1\n");
	else
	{
		for (i=1;i<=n;i++) if (i!=v) printf("%d %d\n",i,v);
		s=n-1;
		for (i=1;i<=n;i++)
			for (j=i+1;j<=n;j++)
			{
				if (s==m) return 0;
				if (i!=v && j!=v)
				{
					s++;
					printf("%d %d\n",i,j);
				}
			}
	}
}


#include<stdio.h>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
long long a[100010],b[100010]={0},c[100010]={0},d[100010],e[100010];
long long lcm(long long x,long long y)
{
	long long t;
	t=min(x,y); x=x+y-t;
	while (x%t!=0)
	{
		y=x%t;
		x=t;
		t=y;
	}
	return t;
}
int main()
{
	//char s[110][110],c[110];
	//const double pie=3.1415926535898;
	int n,m,i,j,k,t,s1,v,s,s2,ans;
	long long x;
	//double d,l1,l2,al,be,l,x,y,H,D,h;
	bool t1,t2;
	scanf("%d%d%d",&n,&m,&v);
	x=n*(n-1)/2-n+2;
	if (x<m || m<n-1) printf("-1\n");
	else
	{
		for (i=1;i<=n;i++) {if (i!=v) printf("%d %d\n",i,v); a[i]=0;}
		a[v]=1;
		s=n-1;
		if (v!=1)
		for (i=2;i<=n;i++)
			for (j=i+1;j<=n;j++)
			{
				if (s==m) return 0;
				if (a[i]==0 && a[j]==0)
				{
					a[i]=1; a[j]=1;
				}
				else if (i!=v && j!=v)
				{
					s++;
					printf("%d %d\n",i,j);
				}
			}
		else
		for (i=1;i<=n-1;i++)
			for (j=i+1;j<=n-1;j++)
			{
				if (s==m) return 0;
				if (a[i]==0 && a[j]==0)
				{
					a[i]=1; a[j]=1;
				}
				else if (i!=v && j!=v)
				{
					s++;
					printf("%d %d\n",i,j);
				}
			}
	}
}


#include<stdio.h>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
long long a[100010],b[100010]={0},c[100010]={0},d[100010],e[100010];
long long lcm(long long x,long long y)
{
	long long t;
	t=min(x,y); x=x+y-t;
	while (x%t!=0)
	{
		y=x%t;
		x=t;
		t=y;
	}
	return t;
}
int main()
{
	//char s[110][110],c[110];
	//const double pie=3.1415926535898;
	int n,m,i,j,k,t,s1,v,s,s2,ans;
	long long x;
	//double d,l1,l2,al,be,l,x,y,H,D,h;
	bool t1,t2;
	scanf("%d%d%d",&n,&m,&v);
	x=n*(n-1)/2-n+1;
	if (x<m || m<n-1) printf("-1\n");
	else
	{
		for (i=1;i<=n;i++) {if (i!=v) printf("%d %d\n",i,v); a[i]=0;}
		a[v]=1;
		s=n-1;
		if (v!=1)
		for (i=2;i<=n;i++)
			for (j=i+1;j<=n;j++)
			{
				if (s==m) return 0;
				if (a[i]==0 && a[j]==0)
				{
					a[i]=1; a[j]=1;
				}
				else if (i!=v && j!=v)
				{
					s++;
					printf("%d %d\n",i,j);
				}
			}
		else
		for (i=1;i<=n-1;i++)
			for (j=i+1;j<=n-1;j++)
			{
				if (s==m) return 0;
				if (a[i]==0 && a[j]==0)
				{
					a[i]=1; a[j]=1;
				}
				else if (i!=v && j!=v)
				{
					s++;
					printf("%d %d\n",i,j);
				}
			}
	}
}


#include<stdio.h>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
long long a[100010],b[100010]={0},c[100010]={0},d[100010],e[100010];
long long lcm(long long x,long long y)
{
	long long t;
	t=min(x,y); x=x+y-t;
	while (x%t!=0)
	{
		y=x%t;
		x=t;
		t=y;
	}
	return t;
}
int main()
{
	//char s[110][110],c[110];
	//const double pie=3.1415926535898;
	int n,m,i,j,k,t,s1,v,s,s2,ans;
	long long x;
	//double d,l1,l2,al,be,l,x,y,H,D,h;
	bool t1,t2;
	scanf("%d%d%d",&n,&m,&v);
	x=n*(n-1)/2-n+2;
	if (x<m || m<n-1) printf("-1\n");
	else
	{
		for (i=1;i<=n;i++) {if (i!=v) printf("%d %d\n",i,v); a[i]=0;}
		a[v]=1;
		s=n-1;
		if (v!=1)
		for (i=2;i<=n;i++)
			for (j=i+1;j<=n;j++)
			{
				if (s==m) return 0;
				if (i!=v && j!=v)
				{
					s++;
					printf("%d %d\n",i,j);
				}
			}
		else
		for (i=1;i<=n-1;i++)
			for (j=i+1;j<=n-1;j++)
			{
				if (s==m) return 0;
				if (i!=v && j!=v)
				{
					s++;
					printf("%d %d\n",i,j);
				}
			}
	}
}


#include<stdio.h>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
long long a[100010],b[100010]={0},c[100010]={0},d[100010],e[100010];
long long lcm(long long x,long long y)
{
	long long t;
	t=min(x,y); x=x+y-t;
	while (x%t!=0)
	{
		y=x%t;
		x=t;
		t=y;
	}
	return t;
}
int main()
{
	//char s[110][110],c[110];
	//const double pie=3.1415926535898;
	int n,m,i,j,k,t,s1,v,s,s2,ans;
	long long x;
	//double d,l1,l2,al,be,l,x,y,H,D,h;
	bool t1,t2;
	scanf("%d%d%d",&n,&m,&v);
	x=n*(n-1)/2-n/2;
	if (x<m || m<n-1) printf("-1\n");
	else
	{
		for (i=1;i<=n;i++) {if (i!=v) printf("%d %d\n",i,v); a[i]=0;}
		a[v]=1;
		s=n-1;
		for (i=1;i<=n;i++)
			for (j=i+1;j<=n;j++)
			{
				if (s==m) return 0;
				if (a[i]==0 && a[j]==0)
				{
					a[i]=1; a[j]=1;
				}
				else if (i!=v && j!=v)
				{
					s++;
					printf("%d %d\n",i,j);
				}
			}
	}
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
    int n, m, v;
    scanf("%d%d%d", &n, &m, &v);
    if (m-n > 1LL * (n-2)*(n-3)/2 || (m < n-1)) {
        puts("-1");
        exit(0);
    }
    vector<pair<int, int>> g;
    for (int i = 1; i <= n && m > 0; i++) {
        if (i != v) {
            g.push_back({v, i});
            m--;
        }
    }
    for (int i = 1; i < n && m > 0; i++) {
        if (i == v) continue;
        for (int j = i+1; j < n && m > 0; j++) {
            if (j == v) continue;
            g.push_back({i, j});
            m--;
        }
    }
    for (int i = 0; i < g.size(); i++) {
        printf("%d %d\n", g[i].first, g[i].second);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
    int n, m, v;
    scanf("%d%d%d", &n, &m, &v);
    if (m-n > 1LL * (n-2)*(n-3)/2 || (m < n-1)) {
        puts("-1");
        exit(0);
    }
    vector<pair<int, int>> g;
    for (int i = 1; i <= n && m > 0; i++) {
        if (i != v) {
            g.push_back({v, i});
            m--;
        }
    }
    int vv = v-1;
    if (!vv) vv = v+1;
    for (int i = 1; i <= n && m > 0; i++) {
        if (i == v || i == vv) continue;
        for (int j = i+1; j <= n && m > 0; j++) {
            if (j == v || j == vv) continue;
            g.push_back({i, j});
            m--;
        }
    }
    for (int i = 0; i < g.size(); i++) {
        printf("%d %d\n", g[i].first, g[i].second);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
    int n, m, v;
    scanf("%d%d%d", &n, &m, &v);
    if (m-n > (n-2)*(n-3)/2) {
        puts("-1");
        exit(0);
    }
    vector<pair<int, int>> g;
    for (int i = 1; i <= n && m > 0; i++) {
        if (i != v) {
            g.push_back({v, i});
            m--;
        }
    }
    for (int i = 1; i <= n && m > 0; i++) {
        if (i == v) continue;
        for (int j = i+1; j <= n && m > 0; j++) {
            if (j == v) continue;
            g.push_back({i, j});
            m--;
        }
    }
    for (int i = 0; i < g.size(); i++) {
        printf("%d %d\n", g[i].first, g[i].second);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
    int n, m, v;
    scanf("%d%d%d", &n, &m, &v);
    if (m-n >= 1LL * (n-2)*(n-3)/2 || (m < n-1)) {
        puts("-1");
        exit(0);
    }
    vector<pair<int, int>> g;
    for (int i = 1; i <= n && m > 0; i++) {
        if (i != v) {
            g.push_back({v, i});
            m--;
        }
    }
    int vv = v-1;
    if (!vv) vv = v+1;
    for (int i = 1; i <= n && m > 0; i++) {
        if (i == v || i == vv) continue;
        for (int j = i+1; j <= n && m > 0; j++) {
            if (j == v || j == vv) continue;
            g.push_back({i, j});
            m--;
        }
    }
    for (int i = 0; i < g.size(); i++) {
        printf("%d %d\n", g[i].first, g[i].second);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
    int n, m, v;
    scanf("%d%d%d", &n, &m, &v);
    if (m-n > n-2) {
        puts("-1");
        exit(0);
    }
    vector<pair<int, int>> g;
    for (int i = 1; i <= n && m > 0; i++) {
        if (i != v) {
            g.push_back({v, i});
            m--;
        }
    }
    for (int i = 1; i <= n && m > 0; i++) {
        if (i == v) continue;
        for (int j = i+1; j <= n && m > 0; j++) {
            if (j == v) continue;
            g.push_back({i, j});
            m--;
        }
    }
    for (int i = 0; i < g.size(); i++) {
        printf("%d %d\n", g[i].first, g[i].second);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
    int n, m, v;
    scanf("%d%d%d", &n, &m, &v);
    if (m-n > 1LL * (n-2)*(n-3)/2 || (m < n-1)) {
        puts("-1");
        exit(0);
    }
    vector<pair<int, int>> g;
    for (int i = 1; i <= n && m > 0; i++) {
        if (i != v) {
            g.push_back({v, i});
            m--;
        }
    }
    for (int i = 1; i <= n && m > 0; i++) {
        if (i == v) continue;
        for (int j = i+1; j < n && m > 0; j++) {
            if (j == v) continue;
            g.push_back({i, j});
            m--;
        }
    }
    for (int i = 0; i < g.size(); i++) {
        printf("%d %d\n", g[i].first, g[i].second);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
    int n, m, v;
    scanf("%d%d%d", &n, &m, &v);
    if (m-n > (n-2)*(n-3)/2) {
        puts("-1");
        exit(0);
    }
    vector<pair<int, int>> g;
    for (int i = 1; i <= n && m > 0; i++) {
        if (i != v) {
            g.push_back({v, i});
            m--;
        }
    }
    for (int i = 1; i <= n && m > 0; i++) {
        if (i == v) continue;
        for (int j = i+1; j < n && m > 0; j++) {
            if (j == v) continue;
            g.push_back({i, j});
            m--;
        }
    }
    for (int i = 0; i < g.size(); i++) {
        printf("%d %d\n", g[i].first, g[i].second);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,v,cz;
int main()
{
	cin>>n>>m>>v;
	if(m<n-1||m>n-1+(n-2)*(n-3)/2)  {cout<<-1;return 0;}
	cz=(v==n)?1:n;
	for(int i=1;i<=n;i++)
		if(i!=v)  cout<<i<<' '<<v<<endl;
	m-=(n-1);
	for(int i=1;i<=n;i++)
		if(i!=v&&i!=cz)
			for(int j=i+1;j<=n;j++)
				if(j!=v&&j!=cz)
				{
					cout<<i<<' '<<j<<endl;
					if(--m==0)  return 0;
				}
}


#include<bits/stdc++.h>
#define INF 1LL << 62
#define ll long long
#define For( X , From , To ) for( int X = From; X <= To; X++ )
using namespace std;
const ll MAXN = 1e5 + 5;
int N , M , V , Cant;
ll QP( ll B , ll K , ll Mod ){ ll Ans = 1; for( ; K; K >>= 1 , B = B * B % Mod ) if( K & 1 ) Ans = Ans * B % Mod; return Ans; }
template <class T> void Read( T &X ){
	X = 0; int F = 0; char Ch = getchar();
	while( Ch < '0' || Ch > '9' ){ F |= ( Ch == '-' ); Ch = getchar(); }
	while( Ch >= '0' && Ch <= '9' ){ X = X * 10 + ( Ch ^ 48 ); Ch = getchar(); }
	X = F ? -X : X;
}
inline void Write( ll X ){
	if( X < 0 ){
		putchar( '-' );
		X = -X;
	}
	if( X > 9 ) Write( X / 10 );
	putchar( ( X % 10 ) ^ 48 );
}
ll GCD( ll X , ll Y ){ return Y == 0 ? X : GCD( Y , X % Y ); }
int main(){
	//freopen( ".in" , "r" , stdin );
	//freopen( ".out" , "w" , stdout );
	Read( N ); Read( M ); Read( V );
	if( M < N - 1 || M > ( N - 1 ) * ( N - 2 ) / 2 + 1 ){
		printf( "-1\n" );
		return 0;
	}
	if( V == 1 ) Cant = N; else Cant = 1;
	for( int i = 1; i <= N; i++ )
	if( i != V ) printf( "%d %d\n" , V , i );
	M = M - N + 1;
	For( i , 1 , N - 1 )
	if( i != V && i != Cant ){
		For( j , i + 1 , N )
		if( j != V && j != Cant ){
			if( !M ) return 0;
			printf( "%d %d\n" , i , j );
			M --;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,v,flag,i,cnt,j;
int main() {
	cin>>n>>m>>v;
	flag=0;
	if((n-1)*(n-2)/2+1<m) flag=1;
	if(m<n-1) flag=1;
	if(flag) {
		printf("-1\n");
		continue;
	}
	cnt=n-1;
	for(i=1; i<n; i++) {
		if(i==2) printf("%d ",v);
		else if(i==v) printf("%d ",2);
		else printf("%d ",i);
		if(i+1==2) printf("%d\n",v);
		else if(i+1==v) printf("%d\n",2);
		else printf("%d\n",i+1);
	}
	for(i=2; i<n&&cnt!=m; i++) {
		for(j=i+2; j<=n&&cnt!=m; j++) {
			cnt++;
			if(i==2) printf("%d ",v);
			else if(i==v) printf("%d ",2);
			else printf("%d ",i);
			if(j==2) printf("%d\n",v);
			else if(j==v) printf("%d\n",2);
			else printf("%d\n",j);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,v,flag,i,cnt,j;
int main() {
	cin>>n>>>m>>v;
	flag=0;
	if((n-1)*(n-2)/2+1<m) flag=1;
	if(m<n-1) flag=1;
	if(flag) {
		printf("-1\n");
		continue;
	}
	cnt=n-1;
	for(i=1; i<n; i++) {
		if(i==2) printf("%d ",v);
		else if(i==v) printf("%d ",2);
		else printf("%d ",i);
		if(i+1==2) printf("%d\n",v);
		else if(i+1==v) printf("%d\n",2);
		else printf("%d\n",i+1);
	}
	for(i=2; i<n&&cnt!=m; i++) {
		for(j=i+2; j<=n&&cnt!=m; j++) {
			cnt++;
			if(i==2) printf("%d ",v);
			else if(i==v) printf("%d ",2);
			else printf("%d ",i);
			if(j==2) printf("%d\n",v);
			else if(j==v) printf("%d\n",2);
			else printf("%d\n",j);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int s[100005];
int main()
{
    int n, m, v;
    cin >> n >> m >> v;
    for (int i = 1; i <= n; i++)
        s[i] = i;
    swap(s[1], s[v]);
    int tmp = min((long long)( 1 + (n - 3) ) * (n - 3) / 2, (long long)m);
    if (m < n - 1 || (m > n - 1 + tmp))
        cout << -1 << endl;
    else
    {
        for (int i = 2; i <= min(n, m); i++)
            cout << s[1] << ' ' << s[i] << endl;
        int num = m - (n - 1);
        for (int i = 3; i <= n - 1 && num > 0; i++)
            for (int j = 2; j < i && num > 0; j++)
            {
                cout << s[j] << ' ' << s[i] << endl;
                num--;
            }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,v,flag,i,cnt,j;
int main() {
	cin>>n>>m>>v;
	flag=0;
	if((n-1)*(n-2)/2+1<m) flag=1;
	if(m<n-1) flag=1;
	if(flag) {
		printf("-1\n");
		return 0;
	}
	cnt=n-1;
	for(i=1; i<n; i++) {
		if(i==2) printf("%d ",v);
		else if(i==v) printf("%d ",2);
		else printf("%d ",i);
		if(i+1==2) printf("%d\n",v);
		else if(i+1==v) printf("%d\n",2);
		else printf("%d\n",i+1);
	}
	for(i=2; i<n&&cnt!=m; i++) {
		for(j=i+2; j<=n&&cnt!=m; j++) {
			cnt++;
			if(i==2) printf("%d ",v);
			else if(i==v) printf("%d ",2);
			else printf("%d ",i);
			if(j==2) printf("%d\n",v);
			else if(j==v) printf("%d\n",2);
			else printf("%d\n",j);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
define int long long
int s[100005];
main()
{
    int n, m, v;
    cin >> n >> m >> v;
    for (int i = 1; i <= n; i++)
        s[i] = i;
    swap(s[1], s[v]);
    int tmp = ( 1 + (n - 3) ) * (n - 3) / 2;
    if (m < n - 1 || (m > n - 1 + tmp))
        cout << -1 << endl;
    else
    {
        for (int i = 2; i <= min(n, m); i++)
            cout << s[1] << ' ' << s[i] << endl;
        int num = m - (n - 1);
        for (int i = 3; i <= n - 1 && num > 0; i++)
            for (int j = 2; j < i && num > 0; j++)
            {
                cout << s[j] << ' ' << s[i] << endl;
                num--;
            }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
define int long long;
int s[100005];
main()
{
    int n, m, v;
    cin >> n >> m >> v;
    for (int i = 1; i <= n; i++)
        s[i] = i;
    swap(s[1], s[v]);
    int tmp = ( 1 + (n - 3) ) * (n - 3) / 2;
    if (m < n - 1 || (m > n - 1 + tmp))
        cout << -1 << endl;
    else
    {
        for (int i = 2; i <= min(n, m); i++)
            cout << s[1] << ' ' << s[i] << endl;
        int num = m - (n - 1);
        for (int i = 3; i <= n - 1 && num > 0; i++)
            for (int j = 2; j < i && num > 0; j++)
            {
                cout << s[j] << ' ' << s[i] << endl;
                num--;
            }
    }
    return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

int a[100005];

int main()
{
	int n,m,v;
	cin>>n>>m>>v;
	if(m<=n-1)
	{
		cout<<"-1"<<endl;
		return 0;
    }
    long long maxx=0;
    for(int i=1;i<=n-2;i++)
    maxx=maxx+i;
    maxx++;
    if(m>maxx)
    {
    	cout<<"-1"<<endl;
    	return 0;
	}
	int point=0;
	if(v==1)
	cout<<1<<" "<<n<<endl;
	else
	cout<<v-1<<" "<<v<<endl;
	m--;
	if(v!=1)
	{
		for(int i=v;i<=n;i++)
    	{
    		point++;
     		a[point]=i;
      	}
    	for(int i=1;i<=v-2;i++)
     	{
	    	point++;
     		a[point]=i;
     	}
	}
	else
	{
		for(int i=1;i<=n-2;i++)
		{
			point++;
			a[point]=i;
		}
	}
	for(int i=1;i<=point-1;i++)
	{
		m--;
		if(a[i]<a[i+1])
		cout<<a[i]<<" "<<a[i+1]<<endl;
		else
		cout<<a[i+1]<<" "<<a[i]<<endl;
	}
	for(int i=1;i<=point-2;i++)
	for(int j=i+2;j<=point;j++)
	{
		if(m==0)
		break;
		if(a[i]<a[j])
		cout<<a[i]<<" "<<a[j]<<endl;
		else
		cout<<a[j]<<" "<<a[i]<<endl;
		m--;
	}
	return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#pragma GCC optimize("Ofast,no-stack-protector")
#define int long long
//#define ull signed long long
#define mm 1000050
//#define nn 500005*200
#define oo 1000000000000
#define ll long long
//ios::sync_with_stdio(false);
//#define mod 998244353

using namespace std;
const double eps=1e-7;

int a[mm];
int n,m,v;
int p;
struct note
{
    int x;int y;
    bool operator<(const note &a)const
    {
        if(a.x!=x){return a.x<x;}
        else{
            return a.y<y;
        }
    }
};

void liuliu()
{
    for(int i=2;i<=n;i++)
    {
        cout<<a[1]<<" "<<a[i]<<endl;
        m--;
    }
    for(int i=2;i<=n-1;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(a[i]==p||a[j]==p){continue;}
            cout<<a[i]<<" "<<a[j]<<endl;
            m--;
            if(m==0){return ;}
        }
    }
}

signed main()
{
    scanf("%lld%lld%lld",&n,&m,&v);
    if(n-1>m||((m-(n-1))>(n-3)*(n-2)/2))
    {
        cout<<"-1"<<endl;
    }
    else if(n-1==m)
    {
        for(int i=1;i<=n;i++)
        {
            if(i==v){continue;}
            cout<<v<<" "<<i<<endl;
        }
    }
    else{
        for(int i=1;i<=n;i++){a[i]=i;}
        a[v]=1;
        a[1]=v;
        if(v==1)
        {
            p=2;
        }
        else{
            p=1;
        }
        liuliu();
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second

using namespace std;

const double pi=acos(-1);
const int N=(int)1e6+7,mod=1000000007,M=2e9;

//scanf("%d",&);
ll n,m,v,x;

int main()
{
//    freopen(".txt","r",stdin);
    cin>>n>>m>>v;
    x=n*(n*1);
    x>>=1;
    x-=n-1;
    if(m<n-1||m>x){cout<<-1;return 0;}
    for(int i=1;i<=n;i++){
        if(i!=v)printf("%d %d\n",i,v);
    }
    bool shit=v==n;
    m-=n-1;
    while(m){
        for(int i=1;i<n-shit;i++){
            if(i!=v){
                for(int j=i+1;j<n-shit;j++){
                    if(j!=v){
                        printf("%d %d\n",i,j);
                        m--;
                    }
                    if(!m)return 0;
                }
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second

using namespace std;

const double pi=acos(-1);
const int N=(int)1e6+7,mod=1000000007,M=2e9;

//scanf("%d",&);
ll n,m,v;

int main()
{
//    freopen(".txt","r",stdin);
    cin>>n>>m>>v;
    if(m<n-1||m>n*(n-2)+1){cout<<-1;return 0;}
    for(int i=1;i<=n;i++){
        if(i!=v)printf("%d %d\n",i,v);
    }
    bool shit=v==n;
    m-=n-1;
    while(m){
        for(int i=1;i<n-shit;i++){
            if(i!=v){
                for(int j=i+1;j<n-shit;j++){
                    if(j!=v){
                        printf("%d %d\n",i,j);
                        m--;
                    }
                    if(!m)return 0;
                }
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second

using namespace std;

const double pi=acos(-1);
const int N=(int)1e6+7,mod=1000000007,M=2e9;

//scanf("%d",&);
ll n,m,v;

int main()
{
//    freopen(".txt","r",stdin);
    cin>>n>>m>>v;
    if(m<n-1||m>=n*(n-1)){cout<<-1;return 0;}
    for(int i=1;i<=n;i++){
        if(i!=v)printf("%d %d\n",i,v);
    }
    m-=n-1;
    while(m){
        for(int i=1;i<=n;i++){
            if(i!=v){
                for(int j=i+1;j<=n;j++){
                    if(j!=v){
                        printf("%d %d\n",i,j);
                        m--;
                    }
                    if(!m)return 0;
                }
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second

using namespace std;

const double pi=acos(-1);
const int N=(int)1e6+7,mod=1000000007,M=2e9;

//scanf("%d",&);
ll n,m,v;

int main()
{
//    freopen(".txt","r",stdin);
    cin>>n>>m>>v;
    if(m<n-1||m>n*(n-2)+1){cout<<-1;return 0;}
    for(int i=1;i<=n;i++){
        if(i!=v)printf("%d %d\n",i,v);
    }
    m-=n-1;
    while(m){
        for(int i=1;i<n;i++){
            if(i!=v){
                for(int j=i+1;j<n;j++){
                    if(j!=v){
                        printf("%d %d\n",i,j);
                        m--;
                    }
                    if(!m)return 0;
                }
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second

using namespace std;

const double pi=acos(-1);
const int N=(int)1e6+7,mod=1000000007,M=2e9;

//scanf("%d",&);
ll n,m,v,x=1;

int main()
{
//    freopen(".txt","r",stdin);
    cin>>n>>m>>v;
    for(int j=n-2;j>0;j--)x+=j;

    if(m<n-1||m>x){cout<<-1;return 0;}
    for(int i=1;i<=n;i++){
        if(i!=v)printf("%d %d\n",i,v);
    }
    bool shit=v==n;
    m-=n-1;
    while(m){
        for(int i=1;i<n-shit;i++){
            if(i!=v){
                for(int j=i+1;j<n-shit;j++){
                    if(j!=v){
                        printf("%d %d\n",i,j);
                        m--;
                    }
                    if(!m)return 0;
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,v;
int sums(int num)
{
        if (num>1023)return 1048576;
        return ((num)*(num-1))/2;
}
int main()
{
        cin>>n>>m>>v;
        if (m+1<n)///Must Be Connected
        {
                cout<<-1<<endl;
                return 0;
        }
        int cnt1=1;
        int cnt2=n-1;
        if (sums(cnt1)+sums(cnt2)+n-1<m)
        {
                cout<<-1<<endl;
                return 0;
        }
        int i,cnt;
        for (i=1;i<=n;i++)
        {
                if (i==v)i++;
                cout<<i<<" "<<v<<endl;
        }
        int end1;
        int end2;
        if (cnt1>=v)end1=cnt1+1;
        else end1=cnt1;
        if (n+1-cnt1<=v)end2=n-cnt2;
        else end2=n-cnt2;
        m-=n-1;
        int i1,i2;
        for (i1=end1;i1<=n;i1++)
        {
                if (i1==v)continue;
                for (i2=i1+1;i2<=n;i2++)
                {
                        if (i2==v)continue;
                        if (m==0)return 0;
                        cout<<i1<<" "<<i2<<endl;
                        m--;
                }
        }
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,v;
int sums(int num)
{
        if (num>1023)return 1048576;
        return ((num)*(num-1))/2;
}
int main()
{
        cin>>n>>m>>v;
        if (m+1<n)///Must Be Connected
        {
                cout<<-1<<endl;
                return 0;
        }
        int cnt1=1;
        int cnt2=n-2;
        if (sums(cnt1)+sums(cnt2)+n-1<m)
        {
                cout<<-1<<endl;
                return 0;
        }
        int i,cnt;
        for (i=1;i<=n;i++)
        {
                if (i==v)i++;
                cout<<i<<" "<<v<<endl;
        }
        int end1;
        int end2;
        if (cnt1>=v)end1=cnt1+1;
        else end1=cnt1;
        if (n+1-cnt1<=v)end2=n-cnt2;
        else end2=n+1-cnt2;
        m-=n-1;
        int i1,i2;
        for (i1=end2;i1<=n;i1++)
        {
                if (i1==v)continue;
                for (i2=i1+1;i2<=n;i2++)
                {
                        if (i2==v)continue;
                        if (m==0)return 0;
                        cout<<i1<<" "<<i2<<endl;
                        m--;
                }
        }
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,v;
int sums(int num)
{
        if (num>1023)return 1048576;
        return ((num)*(num-1))/2;
}
int main()
{
        cin>>n>>m>>v;
        if (m+1<n)///Must Be Connected
        {
                cout<<-1<<endl;
                return 0;
        }
        int cnt1=1;
        int cnt2=n-2;
        if (sums(cnt1)+sums(cnt2)+n-1<m)
        {
                cout<<-1<<endl;
                return 0;
        }
        int i,cnt;
        for (i=1;i<=n;i++)
        {
                if (i==v)i++;
                if (i<=n)cout<<i<<" "<<v<<endl;
        }
        int end1;
        int end2;
        if (cnt1>=v)end1=cnt1+1;
        else end1=cnt1;
        if (n+1-cnt2<=v)end2=n-cnt2;
        else end2=n+1-cnt2;
        m-=n-1;
        int i1,i2;
        for (i1=end2;i1<=n;i1++)
        {
                if (i1==v)continue;
                for (i2=i1+1;i2<=n;i2++)
                {
                        if (i2==v)continue;
                        if (m==0)return 0;
                        cout<<i1<<" "<<i2<<endl;
                        m--;
                }
        }
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,v;
int sums(int num)
{
        if (num>1023)return 1048576;
        return ((num)*(num-1))/2;
}
int main()
{
        cin>>n>>m>>v;
        if (m+1<n)///Must Be Connected
        {
                cout<<-1<<endl;
                return 0;
        }
        int cnt1=1;
        int cnt2=n-2;
        if (sums(cnt1)+sums(cnt2)+n-1<m)
        {
                cout<<-1<<endl;
                return 0;
        }
        int i,cnt;
        for (i=1;i<=n;i++)
        {
                if (i==v)i++;
                cout<<i<<" "<<v<<endl;
        }
        int end1;
        int end2;
        if (cnt1>=v)end1=cnt1+1;
        else end1=cnt1;
        if (n+1-cnt2<=v)end2=n-cnt2;
        else end2=n+1-cnt2;
        m-=n-1;
        int i1,i2;
        for (i1=end2;i1<=n;i1++)
        {
                if (i1==v)continue;
                for (i2=i1+1;i2<=n;i2++)
                {
                        if (i2==v)continue;
                        if (m==0)return 0;
                        cout<<i1<<" "<<i2<<endl;
                        m--;
                }
        }
        return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF (ll)1e12
#define MX 5000000
#define sz(a) (ll)a.size()
using namespace std;
int main(){

  ll n,m,v;
  cin>>n>>m>>v;

  if ( (m >= n-1) && ( m <= (n*(n-1))/2 ) ){

    if (  m - (n-1) > ((n-1)*(n-2))/2 ){
      cout<<"-1";
      return 0;
    }

     ll cnt = 0;
     for (int i=1; i <= n ;i++){
      if (i != v){
        cout<<i<<" "<<v<<"\n";
        ++cnt;
      }
     }

       for (int i=1; i <= n ;i++){
         for (int j=i+1 ; j <= n ; j++){
           if ( i!=j && i!=v && j!=v ){
            cout<<i<<" "<<j<<"\n";
            ++cnt;
            if ( cnt == m)
              return 0;
           }
         }
       }

  }
  else
    cout<<"-1";
 return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF (ll)1e12
#define MX 5000000
#define sz(a) (ll)a.size()
using namespace std;
int main(){

  ll n,m,v;
  cin>>n>>m>>v;

  if ( (m >= n-1) && ( m <= (n*(n-1))/2 ) ){

    if (  m - (n-1) > ((n-1)*(n-2))/2 ){
      cout<<"-1";
      return 0;
    }

     ll cnt = 0;
     for (int i=1; i <= n ;i++){
      if (i != v){
        cout<<i<<" "<<v<<"\n";
        ++cnt;
      }
     }

       for (int i=1; i <= n ;i++){
         for (int j=1 ; j <= n ; j++){
           if ( i!=j && i!=v && j!=v ){
            cout<<i<<" "<<j<<"\n";
            ++cnt;
            if ( cnt == m)
              return 0;
           }
         }
       }

  }
  else
    cout<<"-1";
 return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF (ll)1e12
#define MX 5000000
#define sz(a) (ll)a.size()
using namespace std;
int main(){

  ll n,m,v;
  cin>>n>>m>>v;

  if ( m < n-1 ||  m > ((n-1)*(n-2))/2 + 1  )
   cout<<"-1";
  else{
    int z;
    if (v==n)
      z = n-1;
    else
      z = n;

    ll cnt = 0;
    for (int i=1; i <= n ; i++){
      if (i != v){
        cout<<i<<" "<<v<<"\n";
        ++cnt;
      }
    }

    for (int i=1 ; i <= n && cnt<m ; i++){
      for (int j=i+1;j<=n && cnt<m;j++){
        if (i!=v && i!=z && j!=v && j!=z ){
          cout<<i<<" "<<j<<"\n";
          ++cnt;
        }
      }
    }

  }

 return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF (ll)1e12
#define MX 5000000
#define sz(a) (ll)a.size()
using namespace std;
int main(){

  ll n,m,v;
  cin>>n>>m>>v;

  if ( m < n-1 ||  m > ((n-1)*(n-2))/2 + 1  )
   cout<<"-1";
  else{
    int z;
    if (v==n)
      z = n-1;
    else
      z = n;

    ll cnt = 0;
    for (int i=1; i <= n ; i++){
      if (i != v){
        cout<<i<<" "<<v<<"\n";
        ++cnt;
      }
    }

    for (int i=1 ; i <= n ; i++){
      for (int j=i+1;j<=n;j++){
        if (i!=v && i!=z && j!=v && j!=z ){
          cout<<i<<" "<<j<<"\n";
          ++cnt;
        }
        if ( cnt == m)
          return 0;
      }
    }

  }

 return 0;
}


#include<bits/stdc++.h>
#define FORz(i,t,n) for(int i=t;i<=n;i++)
#define FORf(i,n,t) for(int i=n;i>=t;i--)
#define SCC(x) scanf("%d",&x)
#define PRt(x) printf("%d ",x);
#define IOSS ios::sync_with_stdio(false);cin.tie(0)
#define itt ::iterator it
typedef long long ll;
using namespace std;
const int N=3e5+5;
const int INF=INT_MAX;
const int MOD=1e9+7;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
ll pow1(ll a,ll b){ll r=1;while(b){if(b&1)r=r*a%MOD;a=a*a%MOD;b>>=1;}return r%MOD;}
ll pow2(ll a,ll b,ll mod){ll r=1;while(b){if(b&1)r=r*a%mod;a=a*a%mod;b>>=1;}return r%mod;}
ll gcd(ll a,ll b){ll m=a%b;while(m){a=b;b=m;m=a%b;}return b;}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 d, x, y;exgcd(a, MOD, d, x, y);return d == 1 ? (x + MOD) % MOD : -1;}struct node{ll mat[105][105];};node mul(node x,node y,int n,ll mod){node tmp;for(int i=0;i<n;i++)for(int j=0;j<n;j++){tmp.mat[i][j]=0;for(int k=0;k<n;k++)tmp.mat[i][j]+=(x.mat[i][k]*y.mat[k][j])%mod;tmp.mat[i][j]%=mod;}return tmp;}
node matpow(node x,node y,ll num,int n,ll mod){while(num){if(num&1){y=mul(x,y,n,mod);}x=mul(x,x,n,mod);num=num>>1;}return y;}
int n,m,v;
int main(){
    SCC(n),SCC(m),SCC(v);
    if(m<n-1||m>n-1+(n-2)*(n-3)/2){
        printf("-1");
        return 0;
    }
    FORz(i,1,n)
        if(i-v) printf("%d %d\n",i,v);
    m-=n-1;
    int cv=(v==1)?n:1;
    for(int i=1;i<=n;i++)
        if(i!=v&&i!=cv)
        for(int j=i+1;j<=n;j++)
            if(j!=v&&j!=cv){
                if(!m) return 0;
                printf("%d %d\n",i,j);
                m--;
            }
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int a[100005];

int main()
{
	int n,m,v;
	cin>>n>>m>>v;
	if(m<=n-1)
	{
		cout<<"-1"<<endl;
		return 0;
    }
    int maxx=0;
    for(int i=1;i<=n-2;i++)
    maxx=maxx+i;
    maxx++;
    if(m>maxx)
    {
    	cout<<"-1"<<endl;
    	return 0;
	}
	int point=0;
	if(v==1)
	cout<<n<<" "<<"1"<<endl;
	else
	cout<<v-1<<" "<<v<<endl;
	m--;
	for(int i=v;i<=n;i++)
	{
		point++;
		a[point]=i;
	}
	for(int i=1;i<=v-2;i++)
	{
		point++;
		a[point]=i;
	}
	for(int i=1;i<=point-1;i++)
	{
		m--;
		cout<<a[i]<<" "<<a[i+1]<<endl;
	}
	for(int i=1;i<=point-2;i++)
	for(int j=i+2;j<=point;j++)
	{
		if(m==0)
		return 0;
		else
		{
			cout<<a[i]<<" "<<a[j]<<endl;
			m--;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define R register
#define N 1000001

int n,m,V;
int FR[N],TO[N],top;
int qt[N],qc;

namespace spj{
	int home[N],next[N],to[N],cnt;
	bool vis[N];

	inline void add(int a,int b){
		next[++cnt]=home[a],home[a]=cnt,to[cnt]=b;
	}

	inline void dfs(int x){
		if(vis[x]||x==V) return;
		vis[x]=1;
		for(R int i=home[x];i;i=next[i]){
			R int v=to[i];
			if(v==V||vis[v]) continue;
			dfs(v);
		}
	}

	inline bool pd(){
		R int ltk=0;
		for(R int i=1;i<=n;++i){
			if(!vis[i]&&i!=V) dfs(i),++ltk;
		} return ltk>1;
	}
}

int main(){
	std::cin>>n>>m>>V;
	if(m<n-1){
		puts("-1");
		return 0;
	}
	for(R int i=1;i<=n;++i) if(i!=V) qt[++qc]=i;
	//qt[1]  [qt[2...qc]]
	for(R int i=1;i<=n;++i)
		if(i!=V) FR[++top]=V,TO[top]=i;
	m-=(n-1);
	for(R int i=2;i<=qc;++i){
		if(!m) break;
		for(R int j=i+1;j<=qc;++j){
			if(!m) break;
			FR[++top]=qt[i],TO[top]=qt[j];
			--m;
		}
	}
	if(m){
		puts("-1");
		return 0;
	}
	for(R int i=1;i<=top;++i){
		printf("%d %d\n",FR[i],TO[i]);
		spj::add(FR[i],TO[i]);
		spj::add(TO[i],FR[i]);
	}
//	std::cout<<spj::pd();
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define inf 0x3f3f3f3f
typedef long long LL;
#define cls(x) memset(x,0,sizeof(x))
#define For(i,j,k) for(register int i=(j);i<=(k);++i)
#define Rep(i,j,k) for(register int i=(j);i>=(k);--i)
#define rint register int
#define il inline

il int read(int x=0,int f=1,char ch='0')
{
    while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return f*x;
}

const int N=1e5+5;
int n,m,v;
int id[N],tot;

int main()
{
    scanf("%d%d%d",&n,&m,&v);

    if(m<n-1 || m>(n-1)*(n-2)/2+1) return puts("-1"),0;

    int cut=1+(v==1);
    id[1]=cut; id[2]=v; tot=2;
    for(rint i=1;i<=n;++i) if(i!=cut && i!=v) id[++tot]=i;
    for(rint i=2;i<=n;++i)
    {
        printf("%d %d\n",id[i-1],id[i]);
    }

    m-=(n-1);
    for(rint i=2;i<=n&&m;++i)
    {
        for(rint j=i+2;j<=n&&m;++j)
        {
            printf("%d %d\n",id[i],id[j]); --m;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int s[100005];
int main()
{
    int n, m, v;
    cin >> n >> m >> v;
    for (int i = 1; i <= n; i++)
        s[i] = i;
    swap(s[1], s[v]);
    int tmp = 0;
    if (n > 2) tmp = ( 1 + (n - 3) ) * (n - 3) / 2;
    if (m > n - 1 + tmp)
        cout << -1 << endl;
    else
    {
        for (int i = 1; i <= min(n - 1, m); i++)
            cout << s[1] << ' ' << s[i] << endl;
        int num = m - (n - 1);
        for (int i = 3; i <= n - 1 && num > 0; i++)
            for (int j = 2; j < i && num > 0; j++)
            {
                cout << s[j] << ' ' << s[i] << endl;
                num--;
            }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int s[100005];
int main()
{
    int n, m, v;
    cin >> n >> m >> v;
    for (int i = 1; i <= n; i++)
        s[i] = i;
    swap(s[1], s[v]);
    int tmp = min((long long)( 1 + (n - 3) ) * (n - 3) / 2, m);
    if (m < n - 1 || (m > n - 1 + tmp))
        cout << -1 << endl;
    else
    {
        for (int i = 2; i <= min(n, m); i++)
            cout << s[1] << ' ' << s[i] << endl;
        int num = m - (n - 1);
        for (int i = 3; i <= n - 1 && num > 0; i++)
            for (int j = 2; j < i && num > 0; j++)
            {
                cout << s[j] << ' ' << s[i] << endl;
                num--;
            }
    }
    return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

int a[100005];

int main()
{
	int n,m,v;
	cin>>n>>m>>v;
	if(m<=n)
	{
		cout<<"-1"<<endl;
		return 0;
    }
    long long maxx=0;
    for(int i=1;i<=n-2;i++)
    maxx=maxx+i;
    maxx++;
    if(m>maxx)
    {
    	cout<<"-1"<<endl;
    	return 0;
	}
	int point=0;
	if(v==1)
	cout<<1<<" "<<n<<endl;
	else
	cout<<v-1<<" "<<v<<endl;
	m--;
	if(v!=1)
	{
		for(int i=v;i<=n;i++)
    	{
    		point++;
     		a[point]=i;
      	}
    	for(int i=1;i<=v-2;i++)
     	{
	    	point++;
     		a[point]=i;
     	}
	}
	else
	{
		for(int i=1;i<=n-1;i++)
		{
			point++;
			a[point]=i;
		}
	}
	for(int i=1;i<=point-1;i++)
	{
		m--;
		cout<<a[i]<<" "<<a[i+1]<<endl;
	}
	for(int i=1;i<=point-2;i++)
	for(int j=i+2;j<=point;j++)
	{
		if(m==0)
		break;
		cout<<a[i]<<" "<<a[j]<<endl;
		m--;
	}
	return 0;
}


#include<iostream>
using namespace std;
#define N 100010
int n,m,v;

int main()
{
    cin>>n>>m>>v;
    if(m<n-1||m>(n*n-3*n+4)/2){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++)
        if(i!=v)
            cout<<v<<' '<<i<<endl;
    m-=n-1;
    int p=v==1?1:2;
    for(int i=1;i<=n&&m;i++)
        if(i!=v&&i!=p)
            for(int j=i+1;j<=n&&m;j++)
                if(j!=v&&i!=p)
                    cout<<i<<' '<<j<<endl,m--;
    return 0;
}


#include<bits/stdc++.h>
#define INF 1LL << 62
#define ll long long
#define For( X , From , To ) for( int X = From; X <= To; X++ )
using namespace std;
const ll MAXN = 1e5 + 5;
ll N , M , V , Cant;
ll QP( ll B , ll K , ll Mod ){ ll Ans = 1; for( ; K; K >>= 1 , B = B * B % Mod ) if( K & 1 ) Ans = Ans * B % Mod; return Ans; }
template <class T> void Read( T &X ){
	X = 0; int F = 0; char Ch = getchar();
	while( Ch < '0' || Ch > '9' ){ F |= ( Ch == '-' ); Ch = getchar(); }
	while( Ch >= '0' && Ch <= '9' ){ X = X * 10 + ( Ch ^ 48 ); Ch = getchar(); }
	X = F ? -X : X;
}
inline void Write( ll X ){
	if( X < 0 ){
		putchar( '-' );
		X = -X;
	}
	if( X > 9 ) Write( X / 10 );
	putchar( ( X % 10 ) ^ 48 );
}
ll GCD( ll X , ll Y ){ return Y == 0 ? X : GCD( Y , X % Y ); }
int main(){
	//freopen( ".in" , "r" , stdin );
	//freopen( ".out" , "w" , stdout );
	Read( N ); Read( M ); Read( V );
	if( M < N - 1 || M > ( N - 1 ) * ( N - 2 ) / 2 + 1 ){
		printf( "-1\n" );
		return 0;
	}
	if( V == 1 ) Cant = N; else Cant = 1;
	For( i , 1 , N )
	if( i != V ) printf( "%d %d\n" , V , i );
	M = M - N + 1;
	For( i , 1 , N - 1 )
	if( i != V && i != Cant ){
		For( j , i + 1 , N )
		if( j != V && j != Cant ){
			if( !M ) return 0;
			printf( "%d %d\n" , i , j );
			M --;
		}
	}
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
struct troika
{
	int first;
	int second;
	int value;
};
bool pred(troika a, troika b)
{
	if (a.first == b.first)
		return a.second < b.second;
	else return a.first < b.first;
}
int main()
{
	int n, q;
	cin >> n >> q;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vector<troika>otr(q+1);

	vector<int>b(n);
	int max_l = 1;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == 0)
			b[i] = max_l;
		else
		{
			b[i] = a[i];
			max_l = a[i];
		}
	}

	for (int i = 1; i <= q; i++)
	{
		otr[i].first = -1;
		otr[i].value = i;
	}
	for (int i = 0; i < n; i++)
	{
		otr[b[i]].second = i;
		if (otr[b[i]].first == -1)
			otr[b[i]].first = i;
	}
	sort(otr.begin(), otr.end(),pred);
	bool flag = true;
	for (int i = 1; i < q; i++)
	{
		if (otr[i].second > otr[i + 1].first && otr[i].second < otr[i + 1].second)
		{
			flag = false;
			break;
		}
		if(otr[i].first<otr[i+1].first && otr[i].second>otr[i+1].second && otr[i].value>otr[i+1].value)
		{
			flag = false;
			break;
		}
	}
	if (flag)
	{
		cout << "YES" << endl;
		for (int i = 0; i < n; i++)
			cout << b[i] << " ";
		cout << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
struct troika
{
	int first;
	int second;
	int value;
};
bool pred(troika a, troika b)
{
	if (a.first == b.first)
		return a.second < b.second;
	else return a.first < b.first;
}
int main()
{
	int n, q;
	cin >> n >> q;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vector<troika>otr(q+1);

	vector<int>b(n);
	int max_l = 1;
	/*otr[0].first = 0;
	otr[0].second = n + 2;*/
	for (int i = 1; i <= q; i++)
	{
		otr[i].first = -1;
		otr[i].value = i;
	}
	for (int i = 0; i < n; i++)
	{
		otr[a[i]].second = i;
		if (otr[a[i]].first == -1)
			otr[a[i]].first = i;
	}
	bool flag1 = false;
	if (otr[q].first == -1)
		flag1 = true;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == 0)
		{
			if (flag1)
			{
				flag1 = false;
				b[i] = q;
			}
			else
			b[i] = max_l;
		}
		else
		{
			b[i] = a[i];
			max_l = a[i];
		}
	}

	for (int i = 0; i < n; i++)
	{
		otr[b[i]].second = i;
		if (otr[b[i]].first == -1)
			otr[b[i]].first = i;
	}
	int kol = q;
	otr[0].first = 0;
	otr[0].second = n + 2;
	for (int i = 1; i <= kol; i++)
	{
		while (otr[i].first == -1)
		{

			swap(otr[i], otr[kol]);
			kol--;
		}
	}
	sort(otr.begin(), otr.begin()+kol,pred);
	bool flag = true;
	for (int i = 1; i < kol; i++)
	{
		if (otr[i].second > otr[i + 1].first && otr[i].second < otr[i + 1].second)
		{
			flag = false;
			break;
		}
		if(otr[i].first<otr[i+1].first && otr[i].second>otr[i+1].second && otr[i].value>otr[i+1].value)
		{
			flag = false;
			break;
		}
	}
	if (flag)
	{
		cout << "YES" << endl;
		for (int i = 0; i < n; i++)
			cout << b[i] << " ";
		cout << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
struct troika
{
	int first;
	int second;
	int value;
};
bool pred_m(troika a, troika b)
{
	if (a.first == b.first)
		return a.second < b.second;
	else return a.first < b.first;
}
int main()
{
	int n, q;
	cin >> n >> q;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vector<troika>otr(q+1);

	vector<int>b(n);
	int max_l = 1;

	for (int i = 1; i <= q; i++)
	{
		otr[i].first = -1;
		otr[i].value = i;
	}
	for (int i = 0; i < n; i++)
	{
		otr[a[i]].second = i;
		if (otr[a[i]].first == -1)
			otr[a[i]].first = i;
	}
	bool flag1 = false;
	if (otr[q].first == -1)
		flag1 = true;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == 0)
		{
			if (flag1)
			{
				flag1 = false;
				b[i] = q;
			}
			else
			b[i] = max_l;
		}
		else
		{
			b[i] = a[i];
			max_l = a[i];
		}
	}

	for (int i = 0; i < n; i++)
	{
		otr[b[i]].second = i;
		if (otr[b[i]].first == -1)
			otr[b[i]].first = i;
	}
	int kol = q;
	otr[0].first = -2;
	otr[0].second = -1;
	for (int i = 1; i <= kol; i++)
	{
		while (otr[i].first == -1 && i<=kol)
		{

			swap(otr[i], otr[kol]);
			kol--;
		}
	}
	//sort(otr.begin(), otr.begin()+kol,pred);
	sort(otr.begin(), otr.begin() + kol+1,pred_m);
	bool flag = true;
	for (int i = 1; i < kol; i++)
	{
		if (otr[i].second > otr[i + 1].first && otr[i].second < otr[i + 1].second)
		{
			flag = false;
			break;
		}
		if(otr[i].first<otr[i+1].first && otr[i].second>otr[i+1].second && otr[i].value>otr[i+1].value)
		{
			flag = false;
			break;
		}
	}
	if (flag && !flag1)
	{
		cout << "YES" << endl;
		for (int i = 0; i < n; i++)
			cout << b[i] << " ";
		cout << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	//system("pause");
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], t[4*N], lazy[4*N];
vi q[N], used;

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void update(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    update(tl, tm, ok(v), l, min(r,tm), val);
    update(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
}

bool check(int x, int y, int p, int q)
{
    if(p<=y && q>=y) return 1;
    if(p<=x && q>=x) return 1;
    return 0;
}

void pls_give_AC()
{
    int n,i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
    }
    int cnt=0, fl=0;
    RE(i,n)
    {
        fl = max(fl,a[i]);
        cnt += (a[i]==0);
    }
    if(fl<k && !cnt)
    {
        cout << "NO\n";
        return;
    }
    if(fl<k)
    {
        RE(i,n)
        {
            if(a[i]==0)
            {
                a[i] = k;
                break;
            }
        }
    }
    a[0] = 0, a[n+1] = 0;
    RE(i,n)
    {
        if(!a[i] && a[i+1]) a[i] = a[i+1];
        if(!a[i] && a[i-1]) a[i] = a[i-1];
    }
    int m1,m2;
    for(i=1; i<=k; i++)
    {
        if(!q[i].size()) continue;
        m1 = *q[i].begin(), m2 = *q[i].rbegin();
        update(1,n,1,m1,m2,i);
        i++;
        break;
    }
    for(;i<=k;i++)
    {
        if(!q[i].size())
        {
            used.pb(i);
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(check(m1,m2,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        m1 = min(m1,p1);
        m2 = max(m2,p2);
        update(1,n,1,p1,p2,i);
    }
    cout << "YES\n";
    RE(i,n) cout << a[i] << " "; cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], t[4*N], lazy[4*N];
vi q[N], used;

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void update(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    update(tl, tm, ok(v), l, min(r,tm), val);
    update(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
    t[v] = t[ok(v)] + t[ok(v)+1];
}

int sum(int v, int tl, int tr, int l, int r)
{
    if(l>r) return 0;
    if(tl==l & tr==r) return t[v];
    push(v);
    int tm = (tl+tr) >> 1;
    return sum(ok(v), tl, tm, l, min(r,tm)) + sum(ok(v)+1, tm+1, tr, max(l,tm+1), r);
}

void pls_give_AC()
{
    int n,i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
    }
    int cnt=0, fl=0;
    RE(i,n)
    {
        fl = max(fl,a[i]);
        if(a[i]==0) cnt++;
    }
    if(fl<k && !cnt)
    {
        cout << "NO\n";
        return;
    }
    if(fl<k)
    {
        RE(i,n)
        {
            if(a[i]==0)
            {
                a[i] = k;
                break;
            }
        }
    }
    a[0] = 0, a[n+1] = 0;
    RE(i,n)
    {
        if(!a[i] && a[i-1]) a[i] = a[i-1];
    }
    FO(i,n)
    {
        if(!a[i] && a[i+1]) a[i] = a[i+1];
    }
    RE(i,n) q[a[i]].pb(i);
    int m1,m2;
    for(i=1; i<=k; i++)
    {
        if(!q[i].size()) continue;
        m1 = *q[i].begin(), m2 = *q[i].rbegin();
        update(1,n,1,m1,m2,i);
        i++;
        break;
    }
    for(;i<=k;i++)
    {
        if(!q[i].size())
        {
            used.pb(i);
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(sum(1,1,n,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        m1 = min(m1,p1);
        m2 = max(m2,p2);
        update(1,n,1,p1,p2,i);
    }
    cout << "YES\n";
    RE(i,n) cout << a[i] << " "; cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], t[4*N], lazy[4*N];
vi q[N], used;

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void update(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    update(tl, tm, ok(v), l, min(r,tm), val);
    update(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
}

int get(int v, int tl, int tr, int pos)
{
    if(tl==tr) return t[v];
    push(v);
    int tm = (tl+tr) >> 1;
    if(pos<=tm)
        return get(ok(v), tl, tm, pos);
    return get(ok(v)+1, tm+1, tr, pos);
}

bool check(int x, int y, int p, int q)
{
    if(p<=y && q>=y) return 1;
    if(p<=x && q>=x) return 1;
    return 0;
}

void pls_give_AC()
{
    int n,i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
        q[a[i]].pb(i);
    }
    if(!q[k].size())
    {
        cout << "NO\n";
        return;
    }
    int m1,m2;
    for(i=1; i<=k; i++)
    {
        if(!q[i].size()) continue;
        m1 = *q[i].begin(), m2 = *q[i].rbegin();
        update(1,n,1,m1,m2,i);
        i++;
        break;
    }
    for(;i<=k;i++)
    {
        if(!q[i].size())
        {
            used.pb(i);
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(check(m1,m2,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        m1 = min(m1,p1);
        m2 = max(m2,p2);
        update(1,n,1,p1,p2,i);
    }
    int ans[n+3], flag = 0;
    ans[0] = 0;
    RE(i,n)
    {
        ans[i] = get(1,1,n,i);
    }
    //RE(i,n) cout << ans[i] << " "; cout << "\n";
    ans[n+1] = k;
    ans[0] = 0;
    cout << "YES\n";
    RE(i,n)
    {
        if(!ans[i] && ans[i-1])
        {
            ans[i] = ans[i-1];
            cout << ans[i] <<  " ";
            continue;
        }
        j = i;
        while(!ans[j])
        {
            j++;
        }
        k = --j;
        while(k>=i)
        {
            ans[k] = ans[k+1];
            k--;
        }
        cout << ans[i] << " ";
    }
    cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], t[4*N], lazy[4*N];
vi q[N], used;

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void update(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    update(tl, tm, ok(v), l, min(r,tm), val);
    update(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
}

bool check(int x, int y, int p, int q)
{
    if(p<=y && q>=y) return 1;
    if(p<=x && q>=x) return 1;
    if(x<=p && y>=p) return 1;
    if(x<=q && y>=q) return 1;
    return 0;
}

void pls_give_AC()
{
    int n,i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
    }
    int cnt=0, fl=0;
    RE(i,n)
    {
        fl = max(fl,a[i]);
        if(a[i]==0) cnt++;
    }
    if(fl<k && !cnt)
    {
        cout << "NO\n";
        return;
    }
    if(fl<k)
    {
        RE(i,n)
        {
            if(a[i]==0)
            {
                a[i] = k;
                break;
            }
        }
    }
    a[0] = 0, a[n+1] = 0;
    RE(i,n)
    {
        if(!a[i] && a[i-1]) a[i] = a[i-1];
    }
    FO(i,n)
    {
        if(!a[i] && a[i+1]) a[i] = a[i+1];
    }
    RE(i,n) q[a[i]].pb(i);
    int m1,m2;
    for(i=1; i<=k; i++)
    {
        if(!q[i].size()) continue;
        m1 = *q[i].begin(), m2 = *q[i].rbegin();
        update(1,n,1,m1,m2,i);
        i++;
        break;
    }
    for(;i<=k;i++)
    {
        if(!q[i].size())
        {
            used.pb(i);
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(check(m1,m2,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        m1 = min(m1,p1);
        m2 = max(m2,p2);
        update(1,n,1,p1,p2,i);
    }
    cout << "YES\n";
    RE(i,n) cout << a[i] << " "; cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], t[4*N], lazy[4*N];
vi q[N], used;

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void update(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    update(tl, tm, ok(v), l, min(r,tm), val);
    update(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
}

bool check(int x, int y, int p, int q)
{
    if(p<=y && q>=y) return 1;
    if(p<=x && q>=x) return 1;
    return 0;
}

void pls_give_AC()
{
    int n,i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
    }
    int cnt=0, fl=0;
    RE(i,n)
    {
        fl = max(fl,a[i]);
        if(a[i]==0) cnt++;
    }
    if(fl<k && !cnt)
    {
        cout << "NO\n";
        return;
    }
    if(fl<k)
    {
        RE(i,n)
        {
            if(a[i]==0)
            {
                a[i] = k;
                break;
            }
        }
    }
    a[0] = 0, a[n+1] = 0;
    RE(i,n)
    {
        if(!a[i] && a[i-1]) a[i] = a[i-1];
    }
    FO(i,n)
    {
        if(!a[i] && a[i+1]) a[i] = a[i+1];
    }
    RE(i,n) q[a[i]].pb(i);
    int m1,m2;
    for(i=1; i<=k; i++)
    {
        if(!q[i].size()) continue;
        m1 = *q[i].begin(), m2 = *q[i].rbegin();
        update(1,n,1,m1,m2,i);
        i++;
        break;
    }
    for(;i<=k;i++)
    {
        if(!q[i].size())
        {
            used.pb(i);
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(check(m1,m2,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        m1 = min(m1,p1);
        m2 = max(m2,p2);
        update(1,n,1,p1,p2,i);
    }
    cout << "YES\n";
    RE(i,n) cout << a[i] << " "; cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], t[4*N], lazy[4*N];
vi q[N], used;

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void update(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    update(tl, tm, ok(v), l, min(r,tm), val);
    update(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
}

int get(int v, int tl, int tr, int pos)
{
    if(tl==tr) return t[v];
    push(v);
    int tm = (tl+tr) >> 1;
    if(pos<=tm)
        return get(ok(v), tl, tm, pos);
    return get(ok(v)+1, tm+1, tr, pos);
}

bool check(int x, int y, int p, int q)
{
    if(p<=y && q>=y) return 1;
    if(p<=x && q>=x) return 1;
    return 0;
}

void pls_give_AC()
{
    int n,i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
        q[a[i]].pb(i);
    }
    int m1,m2;
    for(i=1; i<=k; i++)
    {
        if(!q[i].size()) continue;
        m1 = *q[i].begin(), m2 = *q[i].rbegin();
        update(1,n,1,m1,m2,i);
        i++;
        break;
    }
    for(;i<=k;i++)
    {
        if(!q[i].size())
        {
            used.pb(i);
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(check(m1,m2,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        m1 = min(m1,p1);
        m2 = max(m2,p2);
        update(1,n,1,p1,p2,i);
    }
    int ans[n+3], flag = 0;
    ans[0] = 0;
    RE(i,n)
    {
        ans[i] = get(1,1,n,i);
    }
    //RE(i,n) cout << ans[i] << " "; cout << "\n";
    ans[n+1] = k;
    ans[0] = 0;
    cout << "YES\n";
    RE(i,n)
    {
        if(!ans[i] && ans[i-1])
        {
            ans[i] = ans[i-1];
            cout << ans[i] <<  " ";
            continue;
        }
        j = i;
        while(!ans[j])
        {
            j++;
        }
        k = --j;
        while(k>=i)
        {
            ans[k] = ans[k+1];
            k--;
        }
        cout << ans[i] << " ";
    }
    cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], n, t[4*N], lazy[4*N];
vi q[N];

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void rupdate(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    rupdate(tl, tm, ok(v), l, min(r,tm), val);
    rupdate(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
    t[v] = t[ok(v)] + t[ok(v)+1];
}

void update(int l, int r, int val)
{
    rupdate(1, n, 1, l, r, val);
}

int sum(int v, int tl, int tr, int l, int r)
{
    if(l>r) return 0;
    if(tl==l & tr==r) return t[v];
    push(v);
    int tm = (tl+tr) >> 1;
    return sum(ok(v), tl, tm, l, min(r,tm)) + sum(ok(v)+1, tm+1, tr, max(l,tm+1), r);
}

void pls_give_AC()
{
    int i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
    }
    int cnt=0, fl=0;
    RE(i,n)
    {
        fl = max(fl,a[i]);
        if(a[i]==0) cnt++;
    }
    if(fl<k && !cnt)
    {
        cout << "NO\n";
        return;
    }
    if(fl<k)
    {
        RE(i,n)
        {
            if(a[i]==0)
            {
                a[i] = k;
                break;
            }
        }
    }
    a[0] = 0, a[n+1] = 0;
    RE(i,n)
    {
        if(!a[i] && a[i-1]) a[i] = a[i-1];
    }
    FO(i,n)
    {
        if(!a[i] && a[i+1]) a[i] = a[i+1];
    }
    RE(i,n) q[a[i]].pb(i);

    for(i=1;i<=k;i++)
    {
        if(!q[i].size())
        {
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(sum(1,1,n,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        FOR(j,q[i].size())
        {
            update(q[i][j], q[i][j], 1);
        }

    }
    cout << "YES\n";
    RE(i,n) cout << a[i] << " "; cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], t[4*N], lazy[4*N];
vi q[N], used;

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void update(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    update(tl, tm, ok(v), l, min(r,tm), val);
    update(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
}

bool check(int x, int y, int p, int q)
{
    if(p<=y && q>=y) return 1;
    if(p<=x && q>=x) return 1;
    return 0;
}

void pls_give_AC()
{
    int n,i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
    }
    int cnt=0, fl=0;
    RE(i,n)
    {
        fl = (a[i]==k);
        cnt += (a[i]==0);
    }
    if(!fl && !cnt)
    {
        cout << "NO\n";
        return;
    }
    if(!fl)
    {
        RE(i,n)
        {
            if(a[i]==0)
            {
                a[i] = k;
                break;
            }
        }
    }
    REP(i,2,n) if(!a[i] && a[i-1]) a[i] = a[i-1];
    REB(i,n-1,1) if(!a[i] && a[i+1]) a[i] = a[i+1];

    int m1,m2;
    for(i=1; i<=k; i++)
    {
        if(!q[i].size()) continue;
        m1 = *q[i].begin(), m2 = *q[i].rbegin();
        update(1,n,1,m1,m2,i);
        i++;
        break;
    }
    for(;i<=k;i++)
    {
        if(!q[i].size())
        {
            used.pb(i);
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(check(m1,m2,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        m1 = min(m1,p1);
        m2 = max(m2,p2);
        update(1,n,1,p1,p2,i);
    }
    cout << "YES\n";
    RE(i,n) cout << a[i] << " "; cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], t[4*N], lazy[4*N];
vi q[N], used;

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void update(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    update(tl, tm, ok(v), l, min(r,tm), val);
    update(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
}

bool check(int x, int y, int p, int q)
{
    if(p<=y && q>=y) return 1;
    if(p<=x && q>=x) return 1;
    return 0;
}

void pls_give_AC()
{
    int n,i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
    }
    int cnt=0, fl=0;
    RE(i,n)
    {
        fl = max(fl,a[i]);
        if(a[i]==0) cnt++;
    }
    if(fl<k && !cnt)
    {
        cout << "NO\n";
        return;
    }
    if(fl<k)
    {
        RE(i,n)
        {
            if(a[i]==0)
            {
                a[i] = k;
                break;
            }
        }
    }
    a[0] = 0, a[n+1] = 0;
    RE(i,n)
    {
        if(!a[i] && a[i+1]) a[i] = a[i+1];
        if(!a[i] && a[i-1]) a[i] = a[i-1];
    }
    RE(i,n) q[a[i]].pb(i);
    int m1,m2;
    for(i=1; i<=k; i++)
    {
        if(!q[i].size()) continue;
        m1 = *q[i].begin(), m2 = *q[i].rbegin();
        update(1,n,1,m1,m2,i);
        i++;
        break;
    }
    for(;i<=k;i++)
    {
        if(!q[i].size())
        {
            used.pb(i);
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(check(m1,m2,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        m1 = min(m1,p1);
        m2 = max(m2,p2);
        update(1,n,1,p1,p2,i);
    }
    cout << "YES\n";
    RE(i,n) cout << a[i] << " "; cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and Template-------------------------------------//
//#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define rip signed
#define kobe main()
#define bryant ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set <int, greater <int> > :: iterator
#define FOR(i,n) for(int i=0; i<n; i++)
#define RE(i,n) for(int i=1; i<=n; i++)
#define REP(i,j,n) for(int i=j; i<=n; i++)
#define REB(i,j,n) for(int i=j; i>=n; i--)
#define FO(i,n) for(int i=n; i>0; i--)

const int mod = 1e9+7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template Ends------------------------------------------------------/

#define ok(v) 2*v

const int N = 2e5+3;
int a[N], t[4*N], lazy[4*N];
vi q[N], used;

void push(int v)
{
    if(lazy[v])
    {
        t[ok(v)] = t[ok(v)+1] = t[v];
        lazy[ok(v)] = lazy[ok(v)+1] = 1;
        lazy[v] = 0;
    }
}

void update(int tl, int tr, int v, int l, int r, int val)
{
    if(l>r) return;
    if(tl==l && tr==r)
    {
        t[v] = val;
        lazy[v] = 1;
        return;
    }
    push(v);
    int tm = (tl+tr) >> 1;
    update(tl, tm, ok(v), l, min(r,tm), val);
    update(tm+1,tr, ok(v)+1, max(tm+1,l), r, val);
}

int get(int v, int tl, int tr, int pos)
{
    if(tl==tr) return t[v];
    push(v);
    int tm = (tl+tr) >> 1;
    if(pos<=tm)
        return get(ok(v), tl, tm, pos);
    return get(ok(v)+1, tm+1, tr, pos);
}

bool check(int x, int y, int p, int q)
{
    if(p<=y && q>=y) return 1;
    if(p<=x && q>=x) return 1;
    return 0;
}

void pls_give_AC()
{
    int n,i,j,k,m;
    cin >> n >> k;
    RE(i,n)
    {
        cin >> a[i];
        q[a[i]].pb(i);
    }
    if(!q[k].size() && !q[0].size())
    {
        cout << "NO\n";
        return;
    }
    int m1,m2;
    for(i=1; i<=k; i++)
    {
        if(!q[i].size()) continue;
        m1 = *q[i].begin(), m2 = *q[i].rbegin();
        update(1,n,1,m1,m2,i);
        i++;
        break;
    }
    for(;i<=k;i++)
    {
        if(!q[i].size())
        {
            used.pb(i);
            continue;
        }
        int p1 = *q[i].begin(), p2 = *q[i].rbegin();
        //cout << m1 << " " << m2 << " " << p1 << " " << p2 << "\n";
        if(check(m1,m2,p1,p2))
        {
            cout << "NO\n";
            return;
        }
        m1 = min(m1,p1);
        m2 = max(m2,p2);
        update(1,n,1,p1,p2,i);
    }
    int ans[n+3], flag = 0;
    ans[0] = 0;
    RE(i,n)
    {
        ans[i] = get(1,1,n,i);
    }
    //RE(i,n) cout << ans[i] << " "; cout << "\n";
    ans[n+1] = k;
    ans[0] = 0;
    cout << "YES\n";
    RE(i,n)
    {
        if(!ans[i] && ans[i-1])
        {
            ans[i] = ans[i-1];
            cout << ans[i] <<  " ";
            continue;
        }
        j = i;
        while(!ans[j])
        {
            j++;
        }
        k = --j;
        while(k>=i)
        {
            ans[k] = ans[k+1];
            k--;
        }
        cout << ans[i] << " ";
    }
    cout << "\n";
}

rip kobe
{
    bryant;
    //freopen("input.txt", "r", stdin);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        pls_give_AC();
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 found[a[i]]=1;
	 stack<ll> s;
	 s.push(a[i]);
	 maxi=max(maxi,a[i]);
	 i++;
	 for(;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 		 while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	maxi=max(maxi,a[i]);
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {

	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		cout<<"YES\n";
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		ll x;
	 		if(maxi!=q)
	 		{
	 			maxi=q;
	 			x=q;
	 		}
	 		else
	 			x=a[i];
	 		for(j=1;j<i;j++)
	 				a[j]=x;
	 		for(;i<=n;i++)
	 			if(!a[i])
					{ if(maxi==q)
	 					a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 					}
					}
	 			if(maxi!=q)
	 				cout<<"NO\n";
	 			else
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<a[i]<<" ";
	 			}
	 	}
	 }
	}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 found[a[i]]=1;
	 stack<ll> s;
	 s.push(a[i]);
	 maxi=max(maxi,a[i]);
	 i++;
	 for(;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 		 while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	maxi=max(maxi,a[i]);
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {

	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		cout<<"YES\n";
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		for(j=1;j<i;j++)
	 			{
	 				if(maxi!=q)
	 				{
	 					a[j]=q;
	 					maxi=q;
	 				}
	 				else
	 					a[j]=a[i];
	 			}
	 		for(;i<=n;i++)
	 			if(!a[i])
					{
						if(maxi==q)
	 					  a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 		#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 found[a[i]]=1;
	 stack<ll> s;
	 s.push(a[i]);
	 maxi=max(maxi,a[i]);
	 i++;
	 for(;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 		 while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	maxi=max(maxi,a[i]);
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {

	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		cout<<"YES\n";
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		ll x;
	 		if(maxi!=q)
	 		{
	 			maxi=q;
	 			x=q;
	 		}
	 		else
	 			x=a[i];
	 		for(j=1;j<i;j++)
	 				a[j]=x;
	 		for(;i<=n;i++)
	 			if(!a[i])
					{ if(maxi==q)
	 					a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 					}
					}
	 			if(maxi!=q)
	 				cout<<"NO\n";
	 			else
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<a[i]<<" ";
	 			}
	 	}
	 }
	}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}			}
					}
	 			if(maxi!=q)
	 				cout<<"NO\n";
	 			else
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<a[i]<<" ";
	 			}
	 	}
	 }
	}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 found[a[i]]=1;
	 stack<ll> s;
	 s.push(a[i]);
	 maxi=max(maxi,a[i]);
	 i++;
	 for(;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 		 while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	maxi=max(maxi,a[i]);
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {

	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		cout<<"YES\n";
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		ll x;
	 		if(maxi!=q)
	 		{
	 			maxi=q;
	 			x=q;
	 		}
	 		else
	 			x=a[i];
	 		for(j=1;j<i;j++)
	 				a[j]=x;
	 		for(i=1;i<=n;i++)
	 			if(!a[i])
					{ if(maxi==q)
	 					a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 					}
					}
	 			if(maxi!=q)
	 				cout<<"NO\n";
	 			else
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<a[i]<<" ";
	 			}
	 	}
	 }
	}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 		found[a[i]]=1;
	 		stack<ll> s;
	 		s.push(a[i]);
	 		maxi=max(maxi,a[i]);
	 			i++;
	 		for(;i<=n;i++)
	 			if(a[i])
	 		{
	 			if(found[a[i]]==0)
	 			{
	 	   			found[a[i]]=1;
	 	   			while(!s.empty() && s.top()>a[i])
	 	   			{
	 	   	 			small[s.top()]=1;
	 	   	 			s.pop();
	 	   			}
	 	   			if(s.top()!=a[i])
	 	   			s.push(a[i]);
	 			}
	 			else
	 			{
	 				if(small[a[i]])
	 					break;
	 		 		while(!s.empty() && s.top()>a[i])
	 	   			{
	 	   	 			small[s.top()]=1;
	 	   	 			s.pop();
	 	   			}
	 	   			if(s.top()!=a[i])
	 	   			s.push(a[i]);
	 			}
	 			maxi=max(maxi,a[i]);
	 		}
	 		if(i<=n)
	 			cout<<"NO\n";
	 		else
	 		{
	 			i=1;
	 			while(!a[i] && i<=n)
	 				i++;
	 			if(i>n)
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<q<<" ";
	 			}
	 			else
	 			{
	 				for(j=1;j<i;j++)
	 				{
	 					a[j]=q;
	 					maxi=q;
	 				}
	 				for(i=2;i<=n;i++)
	 				if(!a[i])
					{
						if(maxi==q)
	 						a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 					}
					}
	 				if(maxi!=q)
	 				cout<<"NO\n";
	 				else
	 				{
	 					cout<<"YES\n";
	 					for(i=1;i<=n;i++)
	 						cout<<a[i]<<" ";
	 				}
	 			}
	 		}
		}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 found[a[1]]=1;
	 stack<ll> s;
	 s.push(a[1]);
	 for(i=2;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 	}
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {
	 	cout<<"YES\n";
	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		for(j=1;j<i;j++)
	 			a[j]=a[i];
	 		for(i=1;i<=n;i++)
	 			if(a[i])
	 				cout<<a[i]<<" ";
	 			else
	 			{
	 				a[i]=a[i-1];
	 				cout<<a[i]<<" ";
	 			}
	 	}
	 }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 found[a[i]]=1;
	 stack<ll> s;
	 s.push(a[i]);
	 i++;
	 for(;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 		 while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {
	 	cout<<"YES\n";
	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		for(j=1;j<i;j++)
	 			a[j]=a[i];
	 		for(i=1;i<=n;i++)
	 			if(a[i])
	 				cout<<a[i]<<" ";
	 			else
	 			{
	 				a[i]=a[i-1];
	 				cout<<a[i]<<" ";
	 			}
	 	}
	 }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 		found[a[i]]=1;
	 		stack<ll> s;
	 		s.push(a[i]);
	 		maxi=max(maxi,a[i]);
	 			i++;
	 		for(;i<=n;i++)
	 			if(a[i])
	 		{
	 			if(found[a[i]]==0)
	 			{
	 	   			found[a[i]]=1;
	 	   			while(!s.empty() && s.top()>=a[i])
	 	   			{
	 	   	 			small[s.top()]=1;
	 	   	 			s.pop();
	 	   			}
	 	   			s.push(a[i]);
	 			}
	 			else
	 			{
	 				if(small[a[i]])
	 					break;
	 		 		while(!s.empty() && s.top()>=a[i])
	 	   			{
	 	   	 			small[s.top()]=1;
	 	   	 			s.pop();
	 	   			}
	 	   			s.push(a[i]);
	 			}
	 			maxi=max(maxi,a[i]);
	 		}
	 		if(i<=n)
	 			cout<<"NO\n";
	 		else
	 		{
	 			i=1;
	 			while(!a[i] && i<=n)
	 				i++;
	 			if(i>n)
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<q<<" ";
	 			}
	 			else
	 			{
	 				for(j=1;j<i;j++)
	 				{
	 					a[j]=q;
	 					maxi=q;
	 				}
	 				for(i=2;i<=n;i++)
	 				if(!a[i])
					{
						if(maxi==q)
	 						a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 					}
					}
	 				if(maxi!=q)
	 				cout<<"NO\n";
	 				else
	 				{
	 					cout<<"YES\n";
	 					for(i=1;i<=n;i++)
	 						cout<<a[i]<<" ";
	 				}
	 			}
	 		}
		}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 found[a[1]]=1;
	 stack<ll> s;
	 s.push(a[1]);
	 for(i=2;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 		 while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {
	 	cout<<"YES\n";
	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		for(j=1;j<i;j++)
	 			a[j]=a[i];
	 		for(i=1;i<=n;i++)
	 			if(a[i])
	 				cout<<a[i]<<" ";
	 			else
	 			{
	 				a[i]=a[i-1];
	 				cout<<a[i]<<" ";
	 			}
	 	}
	 }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 found[a[i]]=1;
	 stack<ll> s;
	 s.push(a[i]);
	 maxi=max(maxi,a[i]);
	 i++;
	 for(;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 		 while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	maxi=max(maxi,a[i]);
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {

	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		cout<<"YES\n";
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		for(j=1;j<i;j++)
	 			{
	 				if(maxi!=q)
	 				{
	 					a[j]=q;
	 					maxi=q;
	 				}
	 				else
	 					a[j]=a[i];
	 			}
	 		for(;i<=n;i++)
	 			if(!a[i])
					{
						if(maxi==q)
	 					  a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 					}
					}
	 			if(maxi!=q)
	 				cout<<"NO\n";
	 			else
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<a[i]<<" ";
	 			}
	 	}
	 }
	}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 found[a[i]]=1;
	 stack<ll> s;
	 s.push(a[i]);
	 maxi=max(maxi,a[i]);
	 i++;
	 for(;i<=n;i++)
	 	if(a[i])
	 {
	 	if(found[a[i]]==0)
	 	{
	 	   found[a[i]]=1;
	 	   while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	else
	 	{
	 		if(small[a[i]])
	 			break;
	 		 while(!s.empty() && s.top()>a[i])
	 	   {
	 	   	 small[s.top()]=1;
	 	   	 s.pop();
	 	   }
	 	   s.push(a[i]);
	 	}
	 	maxi=max(maxi,a[i]);
	 }
	 if(i<=n)
	 	cout<<"NO\n";
	 else
	 {

	 	i=1;
	 	while(!a[i] && i<=n)
	 		i++;
	 	if(i>n)
	 	{
	 		cout<<"YES\n";
	 		for(i=1;i<=n;i++)
	 			cout<<q<<" ";
	 	}
	 	else
	 	{
	 		ll x;
	 		if(maxi!=q)
	 		{
	 			maxi=q;
	 			x=q;
	 		}
	 		else
	 			x=a[i];
	 		for(j=1;j<i;j++)
	 				a[j]=x;
	 		for(i=2;i<=n;i++)
	 			if(!a[i])
					{ if(maxi==q)
	 					a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 					}
					}
	 			if(maxi!=q)
	 				cout<<"NO\n";
	 			else
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<a[i]<<" ";
	 			}
	 	}
	 }
	}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll found[200005],small[200005];
main()
{
	ll n,q,maxi=0;
	 cin>>n>>q;
	 ll i,j;
	 ll a[n+5];
	 for(i=1;i<=n;i++)
	 	cin>>a[i];
	 for(i=1;i<=n;i++)
	 	if(a[i])
	 		break;
	 	if(i<=n)
	 	{
	 		found[a[i]]=1;
	 		stack<ll> s;
	 		s.push(a[i]);
	 		maxi=max(maxi,a[i]);
	 			i++;
	 		for(;i<=n;i++)
	 			if(a[i])
	 		{
	 			if(found[a[i]]==0)
	 			{
	 	   			found[a[i]]=1;
	 	   			while(!s.empty() && s.top()>a[i])
	 	   			{
	 	   	 			small[s.top()]=1;
	 	   	 			s.pop();
	 	   			}
	 	   			if(!s.empty() && s.top()!=a[i])
	 	   			s.push(a[i]);
	 			}
	 			else
	 			{
	 				if(small[a[i]])
	 					break;
	 		 		while(!s.empty() && s.top()>a[i])
	 	   			{
	 	   	 			small[s.top()]=1;
	 	   	 			s.pop();
	 	   			}
	 	   			if(!s.empty() && s.top()!=a[i])
	 	   			s.push(a[i]);
	 			}
	 			maxi=max(maxi,a[i]);
	 		}
	 		if(i<=n)
	 			cout<<"NO\n";
	 		else
	 		{
	 			i=1;
	 			while(!a[i] && i<=n)
	 				i++;
	 			if(i>n)
	 			{
	 				cout<<"YES\n";
	 				for(i=1;i<=n;i++)
	 					cout<<q<<" ";
	 			}
	 			else
	 			{
	 				for(j=1;j<i;j++)
	 				{
	 					a[j]=q;
	 					maxi=q;
	 				}
	 				for(i=2;i<=n;i++)
	 				if(!a[i])
					{
						if(maxi==q)
	 						a[i]=a[i-1];
	 					else
	 					{
	 						a[i]=q;
	 						maxi=q;
	 					}
					}
	 				if(maxi!=q)
	 				cout<<"NO\n";
	 				else
	 				{
	 					cout<<"YES\n";
	 					for(i=1;i<=n;i++)
	 						cout<<a[i]<<" ";
	 				}
	 			}
	 		}
		}
	else
	{
		cout<<"YES\n";
		for(i=1;i<=n;i++)
			cout<<q<<" ";
	}
}