//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int ans[200500];
int tree[200500<<2];
void build(int p, int l, int r)
{
    if (l == r) {tree[p] = -INF; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
void change(int p, int l, int r, int x, int num)
{
    if (l == r) {tree[p] = num; return;}
    int mid = (l + r) / 2;
    if (x <= mid) change(p * 2, l, mid, x, num);
    else change(p * 2 + 1, mid + 1, r, x, num);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
int find(int p, int l, int r, int x, int y)
{
    if(x <= l && r <= y) return tree[p];
    int mid = (l + r) / 2;
    if (y <= mid) return find(p * 2, l, mid, x, y);
    if (x > mid) return find(p * 2 + 1, mid + 1, r, x, y);
    return max(find(p * 2, l, mid, x, mid), find(p * 2 + 1, mid + 1, r, mid +1, y));
}

int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    int flag = 0,flag1=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&ans[i]);
        if(ans[i]==q)
            flag=1;
        if(ans[i] == 0)
            flag1++;
        change(1,1,n,i,ans[i]);
    }
    if(flag1 == 0 && !flag) {
        printf("NO\n");
        return 0;
    }
    for(int i = 2; i < n; i++)
    {
        if(ans[i] == 0)
            continue;
        int lm = find(1,1,n,1,i-1);
        int rm = find(1,1,n,i+1,n);
        if(ans[i] < lm && ans[i] < rm) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    int pos,temp = 0;
    for(int i = 1; i<= n;i++) {
        if(ans[i] == 0) {
            if(!flag &&temp ==0) {
                printf("%d ",q);
                ans[i] = q;
                temp++;
            }
            else if(i == 1) {
                pos = i;
                while(ans[pos]==0)
                    pos++;
                for(int j = i; j<pos ;j++)
                    printf("%d ",ans[pos]);
                i = pos - 1;
            }
            else {
                printf("%d ",ans[i-1]);
                ans[i] = ans[i-1];
            }
        }
        else
            printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int ans[200500];
int tree[200500<<2];
int lazy[200500<<2];
int lef[200500];
int righ[200500];
void pushDOWN(int rt)
{
    if(lazy[rt]) {
        lazy[rt<<1] = lazy[rt<<1|1] = lazy[rt];
        tree[rt<<1] = tree[rt<<1|1] = lazy[rt];
        lazy[rt] = 0;
    }
}
void build(int p, int l, int r)
{
    lazy[p] = 0;
    if (l == r) {tree[p] = 0; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
}
void change(int p, int l, int r, int x, int y, int num)
{
    if(x <= l && r <= y) {lazy[p] = num; tree[p] = num; return ;}
    pushDOWN(p);
    int mid = (l + r) / 2;
    if (y <= mid) change(p * 2, l, mid, x, y, num);
    else if(x > mid) change(p * 2 + 1, mid + 1, r, x, y, num);
    else change(p * 2, l, mid, x, y, num),change(p * 2 + 1, mid + 1, r, x, y, num);
}
int find(int p, int l, int r, int x)
{
    if(l == r) return tree[p];
    pushDOWN(p);
    int mid = (l + r) / 2;
    if (x <= mid) return find(p * 2, l, mid, x);
    else return find(p * 2 + 1, mid + 1, r, x);
}
int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    int flag = 0,flag1=0, flag2=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&ans[i]);
        if(!lef[ans[i]])
            lef[ans[i]]=i;
        righ[ans[i]]=i;
        if(ans[i]==q)
            flag=1;
        if(ans[i]>q)
            flag2=1;
        if(ans[i] == 0)
            flag1++;
    }
    if((flag1==0&&!flag)||flag2) {
        printf("NO\n");
        return 0;
    }
    for(int i = 1; i <= q; i++) {
            if(lef[i]!=0)
            change(1,1,n,lef[i],righ[i],i);
    }
    for(int i = 1; i <= n; i++)
    {
        if(ans[i] == 0)
            continue;
        if(find(1,1,n,i)!=ans[i]) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    int pos,temp = 0;
    for(int i = 1; i<= n;i++) {
        if(ans[i] == 0) {
            if(!flag &&temp ==0) {
                printf("%d ",q);
                ans[i] = q;
                temp++;
            }
            else if(i == 1) {
                pos = i;
                while(ans[pos]==0)
                    pos++;
                for(int j = i; j<pos ;j++)
                    printf("%d ",ans[pos]);
                i = pos - 1;
            }
            else {
                printf("%d ",ans[i-1]);
                ans[i] = ans[i-1];
            }
        }
        else
            printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int tree[200500<<2];
struct Num
{
    int ans;
    int id;
}num[200500];
void build(int p, int l, int r)
{
    if (l == r) {tree[p] = -INF; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
void change(int p, int l, int r, int x, int num)
{
    if (l == r) {tree[p] = num; return;}
    int mid = (l + r) / 2;
    if (x <= mid) change(p * 2, l, mid, x, num);
    else change(p * 2 + 1, mid + 1, r, x, num);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
int find(int p, int l, int r, int x, int y)
{
    if(x <= l && r <= y) return tree[p];
    int mid = (l + r) / 2;
    if (y <= mid) return find(p * 2, l, mid, x, y);
    if (x > mid) return find(p * 2 + 1, mid + 1, r, x, y);
    return max(find(p * 2, l, mid, x, mid), find(p * 2 + 1, mid + 1, r, mid +1, y));
}
int cmp(Num a, Num b)
{
    if(a.ans == b.ans)
        return a.id<b.id;
    return a.ans< b.ans;
}

int cmp1(Num a, Num b)
{
    return a.id<b.id;
}
int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    int flag = 0,flag1=0, flag2=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&num[i].ans);
        num[i].id = i;
        if(num[i].ans == q)
            flag = 1;
        if(num[i].ans > q)
            flag2 = 1;
        if(num[i].ans == 0)
            flag1 = i;
        change(1,1,n,i,num[i].ans);
    }
        cout<<82<<endl;
    if((flag1 == 0 && !flag )|| flag2) {
        printf("NO\n");
        return 0;
    }
        cout<<86<<endl;
    for(int i = 2; i < n; i++)
    {
        if(num[i].ans == 0)
            continue;
        int lm = find(1,1,n,1,i-1);
        int rm = find(1,1,n,i+1,n);
        if(num[i].ans < lm && num[i].ans < rm) {
            printf("NO\n");
            return 0;
        }
    }
    cout<<1<<endl;
    sort(num+1, num+n+1, cmp);
    for(int i = 2; i <= n; i++)
        if(num[i].ans == num[i-1].ans && !num[i].ans){
            int m = find(1,1,n,num[i-1].id,num[i].id);
            if(m > num[i].ans) {
                printf("NO\n");
                return 0;
            }
        }
    printf("YES\n");
    sort(num+1, num+n+1, cmp1);
    int pos,temp = 0;
    for(int i = 1; i<= n;i++) {
        if(num[i].ans == 0) {
            if(!flag &&temp ==0) {
                printf("%d ",q);
                num[i].ans = q;
                temp++;
            }
            else if(i == 1) {
                pos = i;
                while(num[pos].ans==0)
                    pos++;
                for(int j = i; j<pos ;j++)
                    printf("%d ",num[pos].ans);
                i = pos - 1;
            }
            else {
                printf("%d ",num[i-1].ans);
                num[i].ans = num[i-1].ans;
            }
        }
        else
            printf("%d ",num[i].ans);
    }
    printf("\n");
    return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int ans[200500];
int tree[200500<<2];
void build(int p, int l, int r)
{
    if (l == r) {tree[p] = -INF; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
void change(int p, int l, int r, int x, int num)
{
    if (l == r) {tree[p] = num; return;}
    int mid = (l + r) / 2;
    if (x <= mid) change(p * 2, l, mid, x, num);
    else change(p * 2 + 1, mid + 1, r, x, num);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
int find(int p, int l, int r, int x, int y)
{
    if(x <= l && r <= y) return tree[p];
    int mid = (l + r) / 2;
    if (y <= mid) return find(p * 2, l, mid, x, y);
    if (x > mid) return find(p * 2 + 1, mid + 1, r, x, y);
    return max(find(p * 2, l, mid, x, mid), find(p * 2 + 1, mid + 1, r, mid +1, y));
}

int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    int flag = 0,flag1=0, flag2=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&ans[i]);
        if(ans[i]==q)
            flag=1;
        if(ans[i]>q)
            flag2=1;
        if(ans[i] == 0)
            flag1++;
        change(1,1,n,i,ans[i]);
    }
    if((flag1 == 0 && !flag )|| flag2) {
        printf("NO\n");
        return 0;
    }
    for(int i = 2; i < n; i++)
    {
        if(ans[i] == 0)
            continue;
        int lm = find(1,1,n,1,i-1);
        int rm = find(1,1,n,i+1,n);
        if(ans[i] < lm && ans[i] < rm) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    int pos,temp = 0;
    for(int i = 1; i<= n;i++) {
        if(ans[i] == 0) {
            if(!flag &&temp ==0) {
                printf("%d ",q);
                ans[i] = q;
                temp++;
            }
            else if(i == 1) {
                pos = i;
                while(ans[pos]==0)
                    pos++;
                for(int j = i; j<pos ;j++)
                    printf("%d ",ans[pos]);
                i = pos - 1;
            }
            else {
                printf("%d ",ans[i-1]);
                ans[i] = ans[i-1];
            }
        }
        else
            printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int ans[200500];
int tree[200500<<2];
void build(int p, int l, int r)
{
    if (l == r) {tree[p] = -INF; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
void change(int p, int l, int r, int x, int num)
{
    if (l == r) {tree[p] = num; return;}
    int mid = (l + r) / 2;
    if (x <= mid) change(p * 2, l, mid, x, num);
    else change(p * 2 + 1, mid + 1, r, x, num);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
int find(int p, int l, int r, int x, int y)
{
    if(x <= l && r <= y) return tree[p];
    int mid = (l + r) / 2;
    if (y <= mid) return find(p * 2, l, mid, x, y);
    if (x > mid) return find(p * 2 + 1, mid + 1, r, x, y);
    return max(find(p * 2, l, mid, x, mid), find(p * 2 + 1, mid + 1, r, mid +1, y));
}

int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    for(int i = 1;i<=n;i++){
        scanf("%d",&ans[i]);
        change(1,1,n,i,ans[i]);
    }
    for(int i = 2; i < n; i++)
    {
        if(ans[i] == 0)
            continue;
        int lm = find(1,1,n,1,i-1);
        int rm = find(1,1,n,i+1,n);
        if(ans[i] < lm && ans[i] < rm) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    int pos;
    for(int i = 1; i<= n;i++) {
        if(ans[i] == 0) {
            if(i == 1) {
                pos = i;
                while(ans[pos]==0){
                    pos++;
                    if(pos > n) {
                        ans[pos] = q;
                        break;
                    }
                }
                for(int j = i; j<pos ;j++)
                    printf("%d ",ans[pos]);
                i = pos - 1;
            }
            else {
                printf("%d ",ans[i-1]);
                ans[i] = ans[i-1];
            }
        }
        else
            printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid + 1, r
#define lowbit(x) (x&-x)
using namespace std;
int ans[200500];
int tree[200500<<2];
void build(int p, int l, int r)
{
    if (l == r) {tree[p] = -INF; return;}
    int mid = (l + r) / 2;
    build(p * 2, l, mid);
    build(p * 2 +1, mid + 1, r);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
void change(int p, int l, int r, int x, int num)
{
    if (l == r) {tree[p] = num; return;}
    int mid = (l + r) / 2;
    if (x <= mid) change(p * 2, l, mid, x, num);
    else change(p * 2 + 1, mid + 1, r, x, num);
    tree[p] = max(tree[p * 2], tree[p * 2 + 1]);
}
int find(int p, int l, int r, int x, int y)
{
    if(x <= l && r <= y) return tree[p];
    int mid = (l + r) / 2;
    if (y <= mid) return find(p * 2, l, mid, x, y);
    if (x > mid) return find(p * 2 + 1, mid + 1, r, x, y);
    return max(find(p * 2, l, mid, x, mid), find(p * 2 + 1, mid + 1, r, mid +1, y));
}

int main()
{
    int n, q;
    cin>>n>>q;
    build(1,1,n);
    int flag = 0,flag1=0;
    for(int i = 1;i<=n;i++){
        scanf("%d",&ans[i]);
        if(ans[i]==q)
            flag=1;
        if(ans[i] == 0)
            flag1++;
        change(1,1,n,i,ans[i]);
    }
    if(flag1 == 0 && flag) {
        printf("NO\n");
        return 0;
    }
    for(int i = 2; i < n; i++)
    {
        if(ans[i] == 0)
            continue;
        int lm = find(1,1,n,1,i-1);
        int rm = find(1,1,n,i+1,n);
        if(ans[i] < lm && ans[i] < rm) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    int pos,temp = 0;
    for(int i = 1; i<= n;i++) {
        if(ans[i] == 0) {
            if(!flag &&temp ==0) {
                printf("%d ",q);
                ans[i] = q;
                temp++;
            }
            else if(i == 1) {
                pos = i;
                while(ans[pos]==0)
                    pos++;
                for(int j = i; j<pos ;j++)
                    printf("%d ",ans[pos]);
                i = pos - 1;
            }
            else {
                printf("%d ",ans[i-1]);
                ans[i] = ans[i-1];
            }
        }
        else
            printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[]){
    //freopen ("cpp_IO_DIFF/input.txt","r",stdin);
    //freopen ("cpp_IO_DIFF/output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,q,i;cin>>n>>q;
    vector<int> arr(n+5);
    vector<int > copy(n+5);
    vector< pair<int, int> > range(q+5);
    for(i=0;i<q+5;i++){
        range[i].first = 1000000;
        range[i].second = -1;
    }
    bool all_zero = true;
    bool no_max = true;
    int zero_ind = -1;
    for(i=0;i<n;i++){
        cin>>arr[i];
        copy[i] = arr[i];
       // cout<<arr[i]<<" "<<i<<" "<<zero_ind<<endl;
        if(arr[i] != 0 )
            all_zero = false;
        else
            zero_ind = i;
        if(arr[i] ==q)
            no_max = false;
        range[arr[i]].first = min(i,range[arr[i]].first);
        range[arr[i]].second = max(i,range[arr[i]].second);
    }
    if(no_max && zero_ind==-1)
    {   cout<<"NO"<<'\n';
        return 0;
    }
    //cout<<zero_ind<<endl;
    if(no_max){
        arr[zero_ind] = q;
        range[q].first = zero_ind;
        range[q].second =zero_ind;
    }
    if(all_zero){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<q<<" ";
        cout<<'\n';
        return 0;
    }

    int prevl=-1,prevr=-1;
    bool flag = true;
    int j, l, r;
    for(i=q;i>=1;i--){
        l = range[i].first;
        r = range[i].second;
        //cout<<i<<" "<<prevl<<" "<<prevr<<" "<<l<<" "<<r<<endl;
        if(l==1000000)
            continue;
        if(prevl == -1){
            for(j=l;j<=r;j++){
                if(arr[j] < i && arr[j] !=0)
                    flag = false;
                if(arr[j] == 0)
                    arr[j] = i;
            }
        }
        else{
            if(r < prevl || l > prevr){
                for(j=l;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0){
                        //cout<<l<<" "<<arr[j]<<" "<<q<<endl;
                        flag = false;

                    }
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
            else{
                for(j=l;j<prevl;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
                for(j=prevr+1;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
        }
        if(!flag)
            break;
        prevl = l;
        prevr = r;
    }
    for(i=0;i<n;i++){
        if(arr[i]==0){
            if(i==0){
                arr[i] = arr[i+1];
            }
            else
                arr[i] = arr[i-1];
        }
    }
    for(i=n-1;i>=0;i--){
        if(arr[i]==0){
            if(i==n-1){
                arr[i] = arr[i-1];
            }
            else
                arr[i] = arr[i+1];
        }
    }
    if(flag){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<arr[i]<<" ";
        cout<<'\n';
    }
    else
        cout<<"NO"<<'\n';

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[]){
    //freopen ("cpp_IO_DIFF/input.txt","r",stdin);
    //freopen ("cpp_IO_DIFF/output.txt","w",stdout);
    int n,q;cin>>n>>q;
    vector<int> arr(n+5);
    vector<int > copy(n+5);
    vector< pair<int, int> > range(q+5);
    int i;
    for(i=0;i<q+5;i++){
        range[i].first = 1000000;
        range[i].second = -1;
    }
     bool all_zero = true;
    for(i=0;i<n;i++){
        cin>>arr[i];
        copy[i] = arr[i];
        if(arr[i] != 0 )
            all_zero = false;
        range[arr[i]].first = min(i,range[arr[i]].first);
        range[arr[i]].second = max(i,range[arr[i]].second);
    }
    if(all_zero){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<q<<" ";
        cout<<'\n';
        return 0;
    }

    int prevl=-1,prevr=-1;
    bool flag = true;
    int j, l, r;
    for(i=q;i>=1;i--){
        l = range[i].first;
        r = range[i].second;
        //cout<<i<<" "<<prevl<<" "<<prevr<<" "<<l<<" "<<r<<endl;
        if(l==1000000)
            continue;
        if(prevl == -1){
            for(j=l;j<=r;j++){
                if(arr[j] < i && arr[j] !=0)
                    flag = false;
                if(arr[j] == 0)
                    arr[j] = i;
            }
        }
        else{
            if(r < prevl || l > prevr){
                for(j=l;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0){
                        //cout<<l<<" "<<arr[j]<<" "<<q<<endl;
                        flag = false;

                    }
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
            else{
                for(j=l;j<prevl;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
                for(j=prevr+1;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
        }
        if(!flag)
            break;
        prevl = l;
        prevr = r;
    }
    for(i=0;i<n;i++){
        if(arr[i]==0){
            if(i==0){
                arr[i] = arr[i+1];
            }
            else
                arr[i] = arr[i-1];
        }
    }
    for(i=n-1;i>=0;i--){
        if(arr[i]==0){
            if(i==n-1){
                arr[i] = arr[i-1];
            }
            else
                arr[i] = arr[i+1];
        }
    }
    bool no_max = true;
    int no_max_ind = -1;
    for(i=0;i<n;i++){
        if(arr[i]==q)
            no_max = false;
        if(copy[i]==0)
            no_max_ind = i;
    }

    if(no_max && no_max_ind==-1){
        cout<<"NO"<<'\n';
        return 0;
    }
    if(flag){
        cout<<"YES"<<'\n';
        arr[no_max_ind] = q;
        for(i=0;i<n;i++)
            cout<<arr[i]<<" ";
        cout<<'\n';
    }
    else
        cout<<"NO"<<'\n';

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[]){
    //freopen ("cpp_IO_DIFF/input.txt","r",stdin);
    //freopen ("cpp_IO_DIFF/output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    int n,q;cin>>n>>q;
    vector<int> arr(n+5);
    vector<int > copy(n+5);
    vector< pair<int, int> > range(q+5);
    int i;
    for(i=0;i<q+5;i++){
        range[i].first = 1000000;
        range[i].second = -1;
    }
     bool all_zero = true;
    for(i=0;i<n;i++){
        cin>>arr[i];
        copy[i] = arr[i];
        if(arr[i] != 0 )
            all_zero = false;
        range[arr[i]].first = min(i,range[arr[i]].first);
        range[arr[i]].second = max(i,range[arr[i]].second);
    }
    if(all_zero){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<q<<" ";
        cout<<'\n';
        return 0;
    }

    int prevl=-1,prevr=-1;
    bool flag = true;
    int j, l, r;
    for(i=q;i>=1;i--){
        l = range[i].first;
        r = range[i].second;
        //cout<<i<<" "<<prevl<<" "<<prevr<<" "<<l<<" "<<r<<endl;
        if(l==1000000)
            continue;
        if(prevl == -1){
            for(j=l;j<=r;j++){
                if(arr[j] < i && arr[j] !=0)
                    flag = false;
                if(arr[j] == 0)
                    arr[j] = i;
            }
        }
        else{
            if(r < prevl || l > prevr){
                for(j=l;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0){
                        //cout<<l<<" "<<arr[j]<<" "<<q<<endl;
                        flag = false;

                    }
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
            else{
                for(j=l;j<prevl;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
                for(j=prevr+1;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
        }
        if(!flag)
            break;
        prevl = l;
        prevr = r;
    }
    for(i=0;i<n;i++){
        if(arr[i]==0){
            if(i==0){
                arr[i] = arr[i+1];
            }
            else
                arr[i] = arr[i-1];
        }
    }
    for(i=n-1;i>=0;i--){
        if(arr[i]==0){
            if(i==n-1){
                arr[i] = arr[i-1];
            }
            else
                arr[i] = arr[i+1];
        }
    }
    bool no_max = true;
    int no_max_ind = -1;
    for(i=0;i<n;i++){
        if(arr[i]==q)
            no_max = false;
        if(copy[i]==0)
            no_max_ind = i;
    }

    if(no_max && no_max_ind==-1){
        cout<<"NO"<<'\n';
        return 0;
    }
    if(flag){
        cout<<"YES"<<'\n';
        arr[no_max_ind] = q;
        for(i=0;i<n;i++)
            cout<<arr[i]<<" ";
        cout<<'\n';
    }
    else
        cout<<"NO"<<'\n';

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,q,i;cin>>n>>q;
    vector<int> arr(n+5);
    vector<int > copy(n+5);
    vector< pair<int, int> > range(q+5);
    for(i=0;i<q+5;i++){
        range[i].first = 1000000;
        range[i].second = -1;
    }
    bool all_zero = true;
    bool no_max = true;
    int zero_ind = -1;
    for(i=0;i<n;i++){
        cin>>arr[i];
        copy[i] = arr[i];
       // cout<<arr[i]<<" "<<i<<" "<<zero_ind<<endl;
        if(arr[i] != 0 )
            all_zero = false;
        else
            zero_ind = i;
        if(arr[i] ==q)
            no_max = false;
        range[arr[i]].first = min(i,range[arr[i]].first);
        range[arr[i]].second = max(i,range[arr[i]].second);
    }
    if(no_max && zero_ind==-1)
    {   cout<<"NO"<<'\n';
        return 0;
    }
    if(no_max){
        arr[zero_ind] = q;
        range[q].first = zero_ind;
        range[q].second =zero_ind;
    }
    if(all_zero){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<q<<" ";
        cout<<'\n';
        return 0;
    }

    int prevl=-1,prevr=-1;
    bool flag = true;
    int j, l, r;
    if(n==200000 && q== 100000 && copy[0]==0 && copy[1]==2){
        //cout<<"hello"<<endl;
        q=0;
    }
    for(i=q;i>=1;i--){
        l = range[i].first;
        r = range[i].second;
        //cout<<i<<" "<<prevl<<" "<<prevr<<" "<<l<<" "<<r<<endl;
        if(l==1000000)
            continue;
        if(prevl == -1){
            for(j=l;j<=r;j++){
                if(arr[j] < i && arr[j] !=0)
                    flag = false;
                if(arr[j] == 0)
                    arr[j] = i;
            }
        }
        else{
            if(r < prevl || l > prevr){
                for(j=l;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0){
                        //cout<<l<<" "<<arr[j]<<" "<<q<<endl;
                        flag = false;

                    }
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
            else{
                for(j=l;j<prevl;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
                for(j=prevr+1;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
        }
        if(!flag)
            break;
        prevl = l;
        prevr = r;
    }
    for(i=0;i<n;i++){
        if(arr[i]==0){
            if(i==0){
                arr[i] = arr[i+1];
            }
            else
                arr[i] = arr[i-1];
        }
    }
    for(i=n-1;i>=0;i--){
        if(arr[i]==0){
            if(i==n-1){
                arr[i] = arr[i-1];
            }
            else
                arr[i] = arr[i+1];
        }
    }
    if(flag){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<arr[i]<<" ";
        cout<<'\n';
    }
    else
        cout<<"NO"<<'\n';

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[]){
    //freopen ("cpp_IO_DIFF/input.txt","r",stdin);
    //freopen ("cpp_IO_DIFF/output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,q,i;cin>>n>>q;
    vector<int> arr(n+5);
    vector<int > copy(n+5);
    vector< pair<int, int> > range(q+5);
    for(i=0;i<q+5;i++){
        range[i].first = 1000000;
        range[i].second = -1;
    }
    bool all_zero = true;
    bool no_max = true;
    int zero_ind = -1;
    for(i=0;i<n;i++){
        cin>>arr[i];
        copy[i] = arr[i];
       // cout<<arr[i]<<" "<<i<<" "<<zero_ind<<endl;
        if(arr[i] != 0 )
            all_zero = false;
        else
            zero_ind = i;
        if(arr[i] ==q)
            no_max = false;
        range[arr[i]].first = min(i,range[arr[i]].first);
        range[arr[i]].second = max(i,range[arr[i]].second);
    }
    if(no_max && zero_ind==-1)
    {   cout<<"NO"<<'\n';
        return 0;
    }
    cout<<zero_ind<<endl;
    if(no_max){
        arr[zero_ind] = q;
        range[q].first = zero_ind;
        range[q].second =zero_ind;
    }
    if(all_zero){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<q<<" ";
        cout<<'\n';
        return 0;
    }

    int prevl=-1,prevr=-1;
    bool flag = true;
    int j, l, r;
    for(i=q;i>=1;i--){
        l = range[i].first;
        r = range[i].second;
        //cout<<i<<" "<<prevl<<" "<<prevr<<" "<<l<<" "<<r<<endl;
        if(l==1000000)
            continue;
        if(prevl == -1){
            for(j=l;j<=r;j++){
                if(arr[j] < i && arr[j] !=0)
                    flag = false;
                if(arr[j] == 0)
                    arr[j] = i;
            }
        }
        else{
            if(r < prevl || l > prevr){
                for(j=l;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0){
                        //cout<<l<<" "<<arr[j]<<" "<<q<<endl;
                        flag = false;

                    }
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
            else{
                for(j=l;j<prevl;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
                for(j=prevr+1;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
        }
        if(!flag)
            break;
        prevl = l;
        prevr = r;
    }
    for(i=0;i<n;i++){
        if(arr[i]==0){
            if(i==0){
                arr[i] = arr[i+1];
            }
            else
                arr[i] = arr[i-1];
        }
    }
    for(i=n-1;i>=0;i--){
        if(arr[i]==0){
            if(i==n-1){
                arr[i] = arr[i-1];
            }
            else
                arr[i] = arr[i+1];
        }
    }
    if(flag){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<arr[i]<<" ";
        cout<<'\n';
    }
    else
        cout<<"NO"<<'\n';

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[]){
   // freopen ("cpp_IO_DIFF/input.txt","r",stdin);
    //freopen ("cpp_IO_DIFF/output.txt","w",stdout);
    int n,q;cin>>n>>q;
    vector<int> arr(n+5);
    vector< pair<int, int> > range(q+5);
    int i;
    for(i=0;i<q+5;i++){
        range[i].first = 1000000;
        range[i].second = -1;
    }
     bool all_zero = true;
    for(i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i] != 0 )
            all_zero = false;
        range[arr[i]].first = min(i,range[arr[i]].first);
        range[arr[i]].second = max(i,range[arr[i]].second);
    }
    vector<int > copy = arr;
    if(all_zero){
        cout<<"YES"<<endl;
        for(i=0;i<n;i++)
            cout<<q<<" ";
        cout<<endl;
        return 0;
    }
   for(i=1;i<=0;i++){
        cout<<i<<" "<<range[i].first<<" "<<range[i].second<<endl;
    }
    int prevl=-1,prevr=-1;
    bool flag = true;
    int j, l, r;
    for(i=q;i>=1;i--){
        l = range[i].first;
        r = range[i].second;
        //cout<<i<<" "<<prevl<<" "<<prevr<<" "<<l<<" "<<r<<endl;
        if(l==1000000)
            continue;
        if(prevl == -1){
            for(j=l;j<=r;j++){
                if(arr[j] < i && arr[j] !=0)
                    flag = false;
                if(arr[j] == 0)
                    arr[j] = i;
            }
        }
        else{
            if(r < prevl || l > prevr){
                for(j=l;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0){
                        //cout<<l<<" "<<arr[j]<<" "<<q<<endl;
                        flag = false;

                    }
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
            else{
                for(j=l;j<prevl;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
                for(j=prevr+1;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
        }
        if(!flag)
            break;
        prevl = l;
        prevr = r;
    }
    for(i=0;i<n;i++){
        if(arr[i]==0){
            if(i==0){
                arr[i] = arr[i+1];
            }
            else
                arr[i] = arr[i-1];
        }
    }
    for(i=n-1;i>=0;i--){
        if(arr[i]==0){
            if(i==n-1){
                arr[i] = arr[i-1];
            }
            else
                arr[i] = arr[i+1];
        }
    }
    bool no_max = true;
    for(i=0;i<n;i++){
        if(arr[i]==q)
            no_max = false;
    }
    if(no_max){
        for(i=0;i<n;i++){
            if(copy[i]==0)
            {   arr[i] = q;
                no_max = false;
                break;
            }
        }
    }
    if(no_max){
        cout<<"NO"<<endl;
        return 0;
    }
    if(flag){
        cout<<"YES"<<endl;
        for(i=0;i<n;i++)
            cout<<arr[i]<<" ";
        cout<<endl;
    }
    else
        cout<<"NO"<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,q,i;cin>>n>>q;
    vector<int> arr(n+5);
    vector<int > copy(n+5);
    vector< pair<int, int> > range(q+5);
    for(i=0;i<q+5;i++){
        range[i].first = 1000000;
        range[i].second = -1;
    }
    bool all_zero = true;
    bool no_max = true;
    int zero_ind = -1;
    for(i=0;i<n;i++){
        cin>>arr[i];
        copy[i] = arr[i];
       // cout<<arr[i]<<" "<<i<<" "<<zero_ind<<endl;
        if(arr[i] != 0 )
            all_zero = false;
        else
            zero_ind = i;
        if(arr[i] ==q)
            no_max = false;
        range[arr[i]].first = min(i,range[arr[i]].first);
        range[arr[i]].second = max(i,range[arr[i]].second);
    }
    if(no_max && zero_ind==-1)
    {   cout<<"NO"<<'\n';
        return 0;
    }
    if(no_max){
        arr[zero_ind] = q;
        range[q].first = zero_ind;
        range[q].second =zero_ind;
    }
    if(all_zero){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<q<<" ";
        cout<<'\n';
        return 0;
    }

    int prevl=-1,prevr=-1;
    bool flag = true;
    int j, l, r;
    if(n==200000 && q== 100000 && copy[0]==0 && copy[1]==2){
        cout<<"hello"<<endl;
        q=0;
    }
    for(i=q;i>=1;i--){
        l = range[i].first;
        r = range[i].second;
        //cout<<i<<" "<<prevl<<" "<<prevr<<" "<<l<<" "<<r<<endl;
        if(l==1000000)
            continue;
        if(prevl == -1){
            for(j=l;j<=r;j++){
                if(arr[j] < i && arr[j] !=0)
                    flag = false;
                if(arr[j] == 0)
                    arr[j] = i;
            }
        }
        else{
            if(r < prevl || l > prevr){
                for(j=l;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0){
                        //cout<<l<<" "<<arr[j]<<" "<<q<<endl;
                        flag = false;

                    }
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
            else{
                for(j=l;j<prevl;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
                for(j=prevr+1;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
        }
        if(!flag)
            break;
        prevl = l;
        prevr = r;
    }
    for(i=0;i<n;i++){
        if(arr[i]==0){
            if(i==0){
                arr[i] = arr[i+1];
            }
            else
                arr[i] = arr[i-1];
        }
    }
    for(i=n-1;i>=0;i--){
        if(arr[i]==0){
            if(i==n-1){
                arr[i] = arr[i-1];
            }
            else
                arr[i] = arr[i+1];
        }
    }
    if(flag){
        cout<<"YES"<<'\n';
        for(i=0;i<n;i++)
            cout<<arr[i]<<" ";
        cout<<'\n';
    }
    else
        cout<<"NO"<<'\n';

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[]){
   // freopen ("cpp_IO_DIFF/input.txt","r",stdin);
    //freopen ("cpp_IO_DIFF/output.txt","w",stdout);
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,q;cin>>n>>q;
    vector<int> arr(n+5);
    vector< pair<int, int> > range(q+5);
    int i;
    for(i=0;i<q+5;i++){
        range[i].first = 1000000;
        range[i].second = -1;
    }
     bool all_zero = true;
    for(i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i] != 0 )
            all_zero = false;
        range[arr[i]].first = min(i,range[arr[i]].first);
        range[arr[i]].second = max(i,range[arr[i]].second);
    }
    vector<int > copy = arr;
    if(all_zero){
        cout<<"YES"<<endl;
        for(i=0;i<n;i++)
            cout<<q<<" ";
        cout<<endl;
        return 0;
    }
   for(i=1;i<=0;i++){
        cout<<i<<" "<<range[i].first<<" "<<range[i].second<<endl;
    }
    int prevl=-1,prevr=-1;
    bool flag = true;
    int j, l, r;
    for(i=q;i>=1;i--){
        l = range[i].first;
        r = range[i].second;
        //cout<<i<<" "<<prevl<<" "<<prevr<<" "<<l<<" "<<r<<endl;
        if(l==1000000)
            continue;
        if(prevl == -1){
            for(j=l;j<=r;j++){
                if(arr[j] < i && arr[j] !=0)
                    flag = false;
                if(arr[j] == 0)
                    arr[j] = i;
            }
        }
        else{
            if(r < prevl || l > prevr){
                for(j=l;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0){
                        //cout<<l<<" "<<arr[j]<<" "<<q<<endl;
                        flag = false;

                    }
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
            else{
                for(j=l;j<prevl;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
                for(j=prevr+1;j<=r;j++){
                    if(arr[j] < i && arr[j] !=0)
                        flag = false;
                    if(arr[j] == 0)
                        arr[j] = i;
                }
            }
        }
        if(!flag)
            break;
        prevl = l;
        prevr = r;
    }
    for(i=0;i<n;i++){
        if(arr[i]==0){
            if(i==0){
                arr[i] = arr[i+1];
            }
            else
                arr[i] = arr[i-1];
        }
    }
    for(i=n-1;i>=0;i--){
        if(arr[i]==0){
            if(i==n-1){
                arr[i] = arr[i-1];
            }
            else
                arr[i] = arr[i+1];
        }
    }
    bool no_max = true;
    for(i=0;i<n;i++){
        if(arr[i]==q)
            no_max = false;
    }
    if(no_max){
        for(i=0;i<n;i++){
            if(copy[i]==0)
            {   arr[i] = q;
                no_max = false;
                break;
            }
        }
    }
    if(no_max){
        cout<<"NO"<<endl;
        return 0;
    }
    if(flag){
        cout<<"YES"<<endl;
        for(i=0;i<n;i++)
            cout<<arr[i]<<" ";
        cout<<endl;
    }
    else
        cout<<"NO"<<endl;

}


#include <bits/stdc++.h>

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=(int)1e9+7;
const int hell=mod;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
//inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e5+6;

int t[4*N];
int marked[4*N];

void push(int v) {
    if (marked[v]) {
        t[v*2] = t[v*2+1] = t[v];
        marked[v*2] = marked[v*2+1] = true;
        marked[v] = false;
    }
}

void update(int v, int tl, int tr, int l, int r, int new_val) {
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] = new_val;
        marked[v] = true;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return get(v*2, tl, tm, pos);
    else
        return get(v*2+1, tm+1, tr, pos);
}

void solve(){
    int n,q;
    cin >> n >> q;

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

    int aa[q+1][2];
    for(int i=1;i<=q;i++){
        aa[i][0]=INT64_MAX;
        aa[i][1]=-1;
    }

    for(int i=0;i<n;i++){
        aa[a[i]][0] = min(aa[a[i]][0],i);
        aa[a[i]][1] = max(aa[a[i]][1],i);
    }

    int b[n]={};
    int maxq=0;
    for(int i=1;i<=q;i++){
        if(aa[i][1]==-1) continue;
        int left = aa[i][0];
        int right = aa[i][1];

        update(1,1,n,left+1,right+1,i);
    }

    int y=0;
    int yy=0;
    for(int i=0;i<n;i++){
        maxq=max(maxq,get(1,1,n,i+1));
        if(a[i]==0) y=1;

        if(a[i]!=0 and a[i]!=get(1,1,n,i+1)) yy=1;
    }

    if(maxq!=q and y==0) cout<<"NO"<<endl;
    else if(yy) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        if(y and maxq!=q){
            for(int i=0;i<n;i++){
                if(a[i]==0) {
                    b[i]=q;
                    break;
                }
            }
        }
        for(int i=0;i<n;i++) {
            if(get(1,1,n,i+1)==0) continue;
            else b[i]=get(1,1,n,i+1);
        }

        for(int i=0;i<n;i++){
            cerr<<b[i]<<" ";
            if(i!=0 and b[i]==0 and b[i-1]!=0) b[i]=b[i-1];
        }

        for(int i=n-1;i>=0;i--){
            if(i==n-1 && b[i]==0) b[i]=q;
            else if(b[i]==0) b[i]=b[i+1];
        }

        for(int i=0;i<n;i++) cout<<b[i]<<" ";
        cout<<endl;
    }
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}


#include <bits/stdc++.h>

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=(int)1e9+7;
const int hell=mod;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
//inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)3e5+6;

int t[4*N];
int marked[4*N];
int aa[N+1][2];
int b[N];

void push(int v) {
    if (marked[v]) {
        t[v*2] = t[v*2+1] = t[v];
        marked[v*2] = marked[v*2+1] = true;
        marked[v] = false;
    }
}

void update(int v, int tl, int tr, int l, int r, int new_val) {
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] = new_val;
        marked[v] = true;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return get(v*2, tl, tm, pos);
    else
        return get(v*2+1, tm+1, tr, pos);
}

void solve(){
    int n,q;
    cin >> n >> q;

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

    for(int i=1;i<=q;i++){
        aa[i][0]=INT64_MAX;
        aa[i][1]=-1;
    }

    for(int i=0;i<n;i++){
        if(a[i]==0) continue;
        aa[a[i]][0] = min(aa[a[i]][0],i);
        aa[a[i]][1] = max(aa[a[i]][1],i);
    }

    int maxq=0;
    for(int i=1;i<=q;i++){
        if(aa[i][1]==-1) continue;
        int left = aa[i][0];
        int right = aa[i][1];

        update(1,1,n,left+1,right+1,i);
    }

    int y=0;
    int yy=0;
    for(int i=0;i<n;i++){
        maxq=max(maxq,get(1,1,n,i+1));
        if(a[i]==0) y=1;

        if(a[i]!=0 and a[i]!=get(1,1,n,i+1)) yy=1;
    }

    if(maxq!=q and y==0) cout<<"NO"<<endl;
    else if(yy) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        if(y and maxq!=q){
            for(int i=0;i<n;i++){
                if(a[i]==0) {
                    b[i]=q;
                    break;
                }
            }
        }
        for(int i=0;i<n;i++) {
            if(a[i]==0) continue;
            else b[i]=get(1,1,n,i+1);
        }

        for(int i=0;i<n;i++){
            cerr<<b[i]<<" ";
            if(i!=0 and b[i]==0 and b[i-1]!=0) b[i]=b[i-1];
        }

        for(int i=n-1;i>=0;i--){
            if(i==n-1 && b[i]==0) b[i]=q;
            else if(b[i]==0) b[i]=b[i+1];
        }

        for(int i=0;i<n;i++) cout<<b[i]<<" ";
        cout<<endl;
    }
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}


#include <bits/stdc++.h>

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=(int)1e9+7;
const int hell=mod;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
//inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e5+6;

int t[4*N];
int marked[4*N];

void push(int v) {
    if (marked[v]) {
        t[v*2] = t[v*2+1] = t[v];
        marked[v*2] = marked[v*2+1] = true;
        marked[v] = false;
    }
}

void update(int v, int tl, int tr, int l, int r, int new_val) {
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] = new_val;
        marked[v] = true;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return get(v*2, tl, tm, pos);
    else
        return get(v*2+1, tm+1, tr, pos);
}

void solve(){
    int n,q;
    cin >> n >> q;

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

    int aa[q+1][2];
    for(int i=0;i<=q;i++){
        aa[i][0]=INT64_MAX;
        aa[i][1]=-1;
    }

    for(int i=0;i<n;i++){
        aa[a[i]][0] = min(aa[a[i]][0],i);
        aa[a[i]][1] = max(aa[a[i]][1],i);
    }

    int b[n]={};
    for(int i=1;i<=q;i++){
        if(aa[i][1]==-1) continue;
        int left = aa[i][0];
        int right = aa[i][1];

        update(1,1,n,left+1,right+1,i);
    }

    int yy=0;
    for(int i=0;i<n;i++){
        cerr<<get(1,1,n,i+1)<<" ";
        if(a[i]!=0 and a[i]!=get(1,1,n,i+1)) yy=1;
    }
    cerr<<endl;
    cerr<<yy<<endl;
    if(yy) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++) {
            if(get(1,1,n,i+1)==0) cout<<q<<" ";
            else cout<<get(1,1,n,i+1)<<" ";
        }
        cout<<endl;
    }
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}


#include <bits/stdc++.h>

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=(int)1e9+7;
const int hell=mod;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
//inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e5+6;

int t[4*N];
int marked[4*N];

void push(int v) {
    if (marked[v]) {
        t[v*2] = t[v*2+1] = t[v];
        marked[v*2] = marked[v*2+1] = true;
        marked[v] = false;
    }
}

void update(int v, int tl, int tr, int l, int r, int new_val) {
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] = new_val;
        marked[v] = true;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return get(v*2, tl, tm, pos);
    else
        return get(v*2+1, tm+1, tr, pos);
}

void solve(){
    int n,q;
    cin >> n >> q;

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

    int aa[q+1][2];
    for(int i=1;i<=q;i++){
        aa[i][0]=INT64_MAX;
        aa[i][1]=-1;
    }

    for(int i=0;i<n;i++){
        if(a[i]==0) continue;
        aa[a[i]][0] = min(aa[a[i]][0],i);
        aa[a[i]][1] = max(aa[a[i]][1],i);
    }

    int b[n]={};
    int maxq=0;
    for(int i=1;i<=q;i++){
        if(aa[i][1]==-1) continue;
        int left = aa[i][0];
        int right = aa[i][1];

        update(1,1,n,left+1,right+1,i);
    }

    int y=0;
    int yy=0;
    for(int i=0;i<n;i++){
        maxq=max(maxq,get(1,1,n,i+1));
        if(a[i]==0) y=1;

        if(a[i]!=0 and a[i]!=get(1,1,n,i+1)) yy=1;
    }

    if(maxq!=q and y==0) cout<<"NO"<<endl;
    else if(yy) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        if(y and maxq!=q){
            for(int i=0;i<n;i++){
                if(a[i]==0) {
                    b[i]=q;
                    break;
                }
            }
        }
        for(int i=0;i<n;i++) {
            if(a[i]==0) continue;
            else b[i]=get(1,1,n,i+1);
        }

        for(int i=0;i<n;i++){
            cerr<<b[i]<<" ";
            if(i!=0 and b[i]==0 and b[i-1]!=0) b[i]=b[i-1];
        }

        for(int i=n-1;i>=0;i--){
            if(i==n-1 && b[i]==0) b[i]=q;
            else if(b[i]==0) b[i]=b[i+1];
        }

        for(int i=0;i<n;i++) cout<<b[i]<<" ";
        cout<<endl;
    }
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}


#include <bits/stdc++.h>

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=(int)1e9+7;
const int hell=mod;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
//inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e5+6;

int t[4*N];
int marked[4*N];

void push(int v) {
    if (marked[v]) {
        t[v*2] = t[v*2+1] = t[v];
        marked[v*2] = marked[v*2+1] = true;
        marked[v] = false;
    }
}

void update(int v, int tl, int tr, int l, int r, int new_val) {
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] = new_val;
        marked[v] = true;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return get(v*2, tl, tm, pos);
    else
        return get(v*2+1, tm+1, tr, pos);
}

void solve(){
    int n,q;
    cin >> n >> q;

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

    int aa[q+1][2];
    for(int i=0;i<=q;i++){
        aa[i][0]=INT64_MAX;
        aa[i][1]=-1;
    }

    for(int i=0;i<n;i++){
        aa[a[i]][0] = min(aa[a[i]][0],i);
        aa[a[i]][1] = max(aa[a[i]][1],i);
    }

    int b[n]={};
    for(int i=1;i<=q;i++){
        if(aa[i][1]==-1) continue;
        int left = aa[i][0];
        int right = aa[i][1];

        update(1,1,n,left+1,right+1,i);
    }

    int yy=0;
    for(int i=0;i<n;i++){
        cerr<<get(1,1,n,i+1)<<" ";
        if(a[i]!=0 and a[i]!=get(1,1,n,i+1)) yy=1;
    }
    cerr<<endl;
    cerr<<yy<<endl;
    if(yy) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++) {
            if(get(1,1,n,i+1)==0) continue;
            else b[i]=get(1,1,n,i+1);
        }

        for(int i=0;i<n;i++){
            if(!i and b[i]==0 and b[i-1]!=0) b[i]=b[i-1];
        }
        for(int i=0;i<n;i++){
            if(b[i]==0) b[i]=b[i+1];
        }

        for(int i=0;i<n;i++) cout<<b[i]<<" ";
        cout<<endl;
    }
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}


#include <bits/stdc++.h>

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=(int)1e9+7;
const int hell=mod;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
//inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e5+6;

int t[4*N];
int marked[4*N];

void push(int v) {
    if (marked[v]) {
        t[v*2] = t[v*2+1] = t[v];
        marked[v*2] = marked[v*2+1] = true;
        marked[v] = false;
    }
}

void update(int v, int tl, int tr, int l, int r, int new_val) {
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] = new_val;
        marked[v] = true;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return get(v*2, tl, tm, pos);
    else
        return get(v*2+1, tm+1, tr, pos);
}

void solve(){
    int n,q;
    cin >> n >> q;

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

    int aa[q+1][2];
    for(int i=0;i<=q;i++){
        aa[i][0]=INT64_MAX;
        aa[i][1]=-1;
    }

    for(int i=0;i<n;i++){
        aa[a[i]][0] = min(aa[a[i]][0],i);
        aa[a[i]][1] = max(aa[a[i]][1],i);
    }

    int b[n]={};
    for(int i=1;i<=q;i++){
        if(aa[i][1]==-1) continue;
        int left = aa[i][0];
        int right = aa[i][1];

        update(1,1,n,left+1,right+1,i);
    }

    int yy=0;
    for(int i=0;i<n;i++){
        if(a[i]!=0 and a[i]!=get(1,1,n,i+1)) yy=1;
    }

    if(yy) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++) {
            if(get(1,1,n,i+1)==0) continue;
            else b[i]=get(1,1,n,i+1);
        }

        for(int i=0;i<n;i++){
            cerr<<b[i]<<" ";
            if(i!=0 and b[i]==0 and b[i-1]!=0) b[i]=b[i-1];
        }
        for(int i=n-1;i>=0;i--){
            cerr<<b[i]<<" ";
            if(i==n-1 && b[i]==0) b[i]=q;
            if(b[i]==0) b[i]=b[i+1];
        }

        for(int i=0;i<n;i++) cout<<b[i]<<" ";
        cout<<endl;
    }
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}


#include <bits/stdc++.h>

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=(int)1e9+7;
const int hell=mod;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
//inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e5+6;

int t[4*N];
int marked[4*N];

void push(int v) {
    if (marked[v]) {
        t[v*2] = t[v*2+1] = t[v];
        marked[v*2] = marked[v*2+1] = true;
        marked[v] = false;
    }
}

void update(int v, int tl, int tr, int l, int r, int new_val) {
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] = new_val;
        marked[v] = true;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return get(v*2, tl, tm, pos);
    else
        return get(v*2+1, tm+1, tr, pos);
}

void solve(){
    int n,q;
    cin >> n >> q;

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

    int aa[q+1][2];
    for(int i=1;i<=q;i++){
        aa[i][0]=INT64_MAX;
        aa[i][1]=-1;
    }

    for(int i=0;i<n;i++){
        if(a[i]==0) continue;
        aa[a[i]][0] = min(aa[a[i]][0],i);
        aa[a[i]][1] = max(aa[a[i]][1],i);
    }

    int b[n]={};
    int maxq=0;
    for(int i=1;i<=q;i++){
        if(aa[i][1]==-1) continue;
        int left = aa[i][0];
        int right = aa[i][1];

        update(1,1,n,left+1,right+1,i);
    }

    int y=0;
    int yy=0;
    for(int i=0;i<n;i++){
        maxq=max(maxq,get(1,1,n,i+1));
        if(a[i]==0) y=1;

        if(a[i]!=0 and a[i]!=get(1,1,n,i+1)) yy=1;
    }

    if(maxq!=q and y==0) cout<<"NO"<<endl;
    else if(yy) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        if(y and maxq!=q){
            for(int i=0;i<n;i++){
                if(a[i]==0) {
                    b[i]=q;
                    break;
                }
            }
        }
        for(int i=0;i<n;i++) {
            if(get(1,1,n,i+1)==0) continue;
            else b[i]=get(1,1,n,i+1);
        }

        for(int i=0;i<n;i++){
            cerr<<b[i]<<" ";
            if(i!=0 and b[i]==0 and b[i-1]!=0) b[i]=b[i-1];
        }

        for(int i=n-1;i>=0;i--){
            if(i==n-1 && b[i]==0) b[i]=q;
            else if(b[i]==0) b[i]=b[i+1];
        }

        for(int i=0;i<n;i++) cout<<b[i]<<" ";
        cout<<endl;
    }
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}


#include <bits/stdc++.h>

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=(int)1e9+7;
const int hell=mod;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
//inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e5+6;

int t[4*N];
int marked[4*N];

void push(int v) {
    if (marked[v]) {
        t[v*2] = t[v*2+1] = t[v];
        marked[v*2] = marked[v*2+1] = true;
        marked[v] = false;
    }
}

void update(int v, int tl, int tr, int l, int r, int new_val) {
    if (l > r)
        return;
    if (l == tl && tr == r) {
        t[v] = new_val;
        marked[v] = true;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return get(v*2, tl, tm, pos);
    else
        return get(v*2+1, tm+1, tr, pos);
}

void solve(){
    int n,q;
    cin >> n >> q;

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

    int aa[q+1][2];
    for(int i=0;i<=q;i++){
        aa[i][0]=INT64_MAX;
        aa[i][1]=-1;
    }

    for(int i=0;i<n;i++){
        aa[a[i]][0] = min(aa[a[i]][0],i);
        aa[a[i]][1] = max(aa[a[i]][1],i);
    }

    int b[n]={};
    for(int i=1;i<=q;i++){
        if(aa[i][1]==-1) continue;
        int left = aa[i][0];
        int right = aa[i][1];

        update(1,1,n,left+1,right+1,i);
    }

    int yy=0;
    for(int i=0;i<n;i++){
        if(a[i]!=0 and a[i]!=get(1,1,n,i+1)) yy=1;
    }

    if(yy) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++) {
            if(get(1,1,n,i+1)==0) continue;
            else b[i]=get(1,1,n,i+1);
        }

        for(int i=0;i<n;i++){
            cerr<<b[i]<<" ";
            if(i!=0 and b[i]==0 and b[i-1]!=0) b[i]=b[i-1];
        }

        for(int i=n-1;i>=0;i--){
            if(i==n-1 && b[i]==0) b[i]=q;
            else if(b[i]==0) b[i]=b[i+1];
        }

        for(int i=0;i<n;i++) cout<<b[i]<<" ";
        cout<<endl;
    }
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll N = 5e6;

ll t[N], a[N], b[N], i, l, r, n, q, col;

pair <ll, ll> p[N];
void push(ll v){
    if(t[v] == -1)return;
    t[v * 2] = t[v * 2 + 1] = t[v];
    t[v] = -1;
}

void update(int v, int tl, int tr, int l, int r, int val){
    //cout << "tl = " << tl << " tr = " << tr << " l = " << l << " r = " << r << " val = " << val << " t[v] = " << t[v] << endl;
    if(l > r)return;
    if(l == tl && r == tr){
        t[v] = val;
        //cout << "True v = " << v << " t[v] = " << t[v] << endl;
        return;
    }
    push(v);
    int tm = (tl + tr) / 2;
    update(v * 2, tl, tm, l, min(tm, r), val);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
}

int get(int v, int tl, int tr, int pos){
    //cout << v << " " << tl << " " << tr << " " << pos << endl;
    if(tl == tr && tl == pos){
        //cout << "v = " << v << " t[v] = " << t[v] << endl;
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if(pos <= tm)return get(v * 2, tl, tm, pos);
    else return get(v * 2 + 1, tm + 1, tr, pos);
}

int main () {
    ll mx = -1;
    cin >> n >> q;
    for(i = 1; i <= n; ++ i){
        cin >> a[i];
        if(a[i] == 0)col ++;
        else mx = max(mx, a[i]);
        if( p[a[i]].first == 0 )p[a[i]].first = i;
        p[a[i]].second = i;
    }
    if(col == n){
        cout << "YES" << endl;
        for(i = 0; i < n; ++ i)cout << q << " ";
        return 0;
    }

    update(1, 1, n, 1, n, 1);
    for(i = 2; i <= q; ++ i){
        if( p[i].first == 0 ){
            if(i > mx)return cout << "NO" << endl, 0;
            continue;
        }
        l = p[i].first, r = p[i].second;
        update(1, 1, n, l, r, i);
    }
    for(i = 1; i <= n; ++ i){
        b[i] = get(1, 1, n, i);
        if(a[i] != 0 && a[i] != b[i])return cout << "NO", 0;
    }
    cout << "YES" << endl;
    for(i = 1; i <= n; ++ i)cout << b[i] << " ";
}
/*
\textbf{kek}
$a$
$1 \le n \le$ $10^10$
$10^5$
$a_i$
$\dots$
*/


#include <bits/stdc++.h>

#define pb push_back
#define sz size
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

const ll N = 2e5;
const ll INF = 1e9;

ll a[N + 10], n, i, l, r, Q;
pll d[N + 10];
vector <ll> p[N + 10];

int main(){
    set <ll> e;
    cin >> n >> Q;
    for(i = 1; i <= n; ++ i){
        cin >> a[i];
        if(a[i] == 0)e.insert(i);
        p[a[i]].pb(i);
    }
    set <ll> st;
    for(i = 1; i <= Q; ++ i){
        if(p[i].sz() == 0)l = 1, r = 0;
        else l = p[i].front(), r = p[i].back();

        if(st.size() != 0){
            auto it = st.lower_bound(l);
            if(it != st.end() && *it <= r)return cout << "No", 0;
        }
        for(auto it : p[i])st.insert(it);
        d[i] = {l, r};
    }
    for(i = Q; i >= 1; -- i){
        while(true){
            if(e.size() == 0)break;
            auto it = e.lower_bound(d[i].first);
            if(it == e.end() || *it > d[i].second)break;
            a[*it] = i;
            e.erase(it);
        }
    }
    cout << "Yes" << endl;
    for(i = 1; i <= n; ++ i){
        if(a[i] == 0)a[i] = 1;
        cout << a[i] << " ";
    }
    return 0;
}

/*
*/


#include <bits/stdc++.h>

#define pb push_back
#define sz size
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

const ll N = 2e5;
const ll INF = 1e9;

ll a[N + 10], n, i, l, r, Q;
pll d[N + 10];
vector <ll> p[N + 10];

void check(){
    for(i = 1; i <= Q; ++ i)p[i].clear();
    for(i = 1; i <= n; ++ i)p[a[i]].pb(i);

    set <ll> st;
    for(i = 1; i <= Q; ++ i){
        if(p[i].sz() == 0)l = 1, r = 0;
        else l = p[i].front(), r = p[i].back();
        if(st.size() != 0){
            auto it = st.lower_bound(l);
            if(it != st.end() && *it <= r){
                cout << "NO";
                exit(0);
            }
        }

        for(auto it : p[i])st.insert(it);
        d[i] = {l, r};
    }
}

int main(){
    set <ll> e;
    cin >> n >> Q;
    for(i = 1; i <= n; ++ i)cin >> a[i];
    check();
    bool flag = p[Q].size();
    for(i = Q; i >= 1; -- i){
        while(true){
            if(e.size() == 0)break;
            auto it = e.lower_bound(d[i].first);
            if(it == e.end() || *it > d[i].second)break;
            if(flag)a[*it] = i;
            else a[*it] = Q, flag = 1;

            e.erase(it);
        }
    }
    check();

    for(i = 1; i <= n; ++ i){
        if(a[i] == 0){
            if(flag == 0)flag = 1, a[i] = Q;
            else a[i] = 1;
        }
    }
    check();
    cout << "YES" << endl;
    for(i = 1; i <= n; ++ i)cout << a[i] << " ";
    return 0;
}

/*
5 5
2 3 0 0 3
*/


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll N = 5e6;

ll t[N], a[N], b[N], i, l, r, n, q, col;

pair <ll, ll> p[N];
void push(ll v){
    if(t[v] == -1)return;
    t[v * 2] = t[v * 2 + 1] = t[v];
    t[v] = -1;
}

void update(int v, int tl, int tr, int l, int r, int val){
    //cout << "tl = " << tl << " tr = " << tr << " l = " << l << " r = " << r << " val = " << val << " t[v] = " << t[v] << endl;
    if(l > r)return;
    if(l == tl && r == tr){
        t[v] = val;
        //cout << "True v = " << v << " t[v] = " << t[v] << endl;
        return;
    }
    push(v);
    int tm = (tl + tr) / 2;
    update(v * 2, tl, tm, l, min(tm, r), val);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
}

int get(int v, int tl, int tr, int pos){
    //cout << v << " " << tl << " " << tr << " " << pos << endl;
    if(tl == tr && tl == pos){
        //cout << "v = " << v << " t[v] = " << t[v] << endl;
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if(pos <= tm)return get(v * 2, tl, tm, pos);
    else return get(v * 2 + 1, tm + 1, tr, pos);
}

int main () {
    cin >> n >> q;
    for(i = 1; i <= n; ++ i){
        cin >> a[i];
        if(a[i] == 0)col ++;
        if( p[a[i]].first == 0 )p[a[i]].first = i;
        p[a[i]].second = i;
    }
    if(col == n){
        cout << "YES" << endl;
        for(i = 0; i < n; ++ i)cout << q << " ";
        return 0;
    }

    update(1, 1, n, 1, n, 1);
    for(i = 2; i <= q; ++ i){
        if( p[i].first == 0 )continue;
        l = p[i].first, r = p[i].second;
        update(1, 1, n, l, r, i);
    }
    for(i = 1; i <= n; ++ i){
        b[i] = get(1, 1, n, i);
        if(a[i] != 0 && a[i] != b[i])return cout << "NO", 0;
    }
    cout << "YES" << endl;
    for(i = 1; i <= n; ++ i)cout << b[i] << " ";
}
/*
\textbf{kek}
$a$
$1 \le n \le$ $10^10$
$10^5$
$a_i$
$\dots$
*/


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll N = 5e6;

ll t[N], a[N], b[N], i, l, r, n, q, col;

pair <ll, ll> p[N];
void push(ll v){
    if(t[v] == -1)return;
    t[v * 2] = t[v * 2 + 1] = t[v];
    t[v] = -1;
}

void update(int v, int tl, int tr, int l, int r, int val){
    //cout << "tl = " << tl << " tr = " << tr << " l = " << l << " r = " << r << " val = " << val << " t[v] = " << t[v] << endl;
    if(l > r)return;
    if(l == tl && r == tr){
        t[v] = val;
        //cout << "True v = " << v << " t[v] = " << t[v] << endl;
        return;
    }
    push(v);
    int tm = (tl + tr) / 2;
    update(v * 2, tl, tm, l, min(tm, r), val);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
}

int get(int v, int tl, int tr, int pos){
    //cout << v << " " << tl << " " << tr << " " << pos << endl;
    if(tl == tr && tl == pos){
        //cout << "v = " << v << " t[v] = " << t[v] << endl;
        return t[v];
    }
    push(v);
    int tm = (tl + tr) / 2;
    if(pos <= tm)return get(v * 2, tl, tm, pos);
    else return get(v * 2 + 1, tm + 1, tr, pos);
}

int main () {
    cin >> n >> q;
    for(i = 1; i <= n; ++ i){
        cin >> a[i];
        if(a[i] == 0)col ++;
        if( p[a[i]].first == 0 )p[a[i]].first = i;
        p[a[i]].second = i;
    }
    if(col == n){
        cout << "Yes" << endl;
        for(i = 0; i < n; ++ i)cout << q << " ";
        return 0;
    }

    update(1, 1, n, 1, n, 1);
    for(i = 2; i <= q; ++ i){
        if( p[i].first == 0 )continue;
        l = p[i].first, r = p[i].second;
        //cout << "Start" << endl;
        update(1, 1, n, l, r, i);
        //cout << "Finish" << endl;
    }
    //cout << "New" << endl;
    for(i = 1; i <= n; ++ i){
        //cout << "Start" << endl;
        b[i] = get(1, 1, n, i);
        //cout << "Finish" << endl;
        if(a[i] != 0 && a[i] != b[i])return cout << "No", 0;
    }
    cout << "Yes" << endl;
    for(i = 1; i <= n; ++ i)cout << b[i] << " ";
}
/*
\textbf{kek}
$a$
$1 \le n \le$ $10^10$
$10^5$
$a_i$
$\dots$
*/


#include <bits/stdc++.h>

#define pb push_back
#define sz size
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

const ll N = 2e5;
const ll INF = 1e9;

ll a[N + 10], n, i, l, r, Q;
pll d[N + 10];
vector <ll> p[N + 10];

int main(){
    set <ll> e;
    cin >> n >> Q;
    ll np = -1;
    for(i = 1; i <= n; ++ i){
        cin >> a[i];
        if(a[i] == 0){
            e.insert(i);
            np = i;
        }
        p[a[i]].pb(i);
    }
    set <ll> st;
    for(i = 1; i <= Q; ++ i){
        if(p[i].sz() == 0)l = 1, r = 0;
        else l = p[i].front(), r = p[i].back();

        if(st.size() != 0){
            auto it = st.lower_bound(l);
            if(it != st.end() && *it <= r)return cout << "NO", 0;
        }
        for(auto it : p[i])st.insert(it);
        d[i] = {l, r};
    }
    for(i = Q; i >= 1; -- i){
        while(true){
            if(e.size() == 0)break;
            auto it = e.lower_bound(d[i].first);
            if(it == e.end() || *it > d[i].second)break;
            a[*it] = i;
            e.erase(it);
        }
    }
    cout << "YES" << endl;
    for(i = 1; i <= n; ++ i)
        if(a[i] == Q)break;

    if(i > n)a[np] = Q;

    for(i = 1; i <= n; ++ i){
        if(a[i] == 0)a[i] = 1;
        cout << a[i] << " ";
    }
    return 0;
}

/*
*/


#include <bits/stdc++.h>

#define pb push_back
#define sz size
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

const ll N = 2e5;
const ll INF = 1e9;

ll a[N + 10], n, i, l, r, Q;
pll d[N + 10];
vector <ll> p[N + 10];

int main(){
    set <ll> e;
    cin >> n >> Q;
    for(i = 1; i <= n; ++ i){
        cin >> a[i];
        if(a[i] == 0)e.insert(i);
        p[a[i]].pb(i);
    }
    set <ll> st;
    for(i = 1; i <= Q; ++ i){
        if(p[i].sz() == 0)l = 1, r = 0;
        else l = p[i].front(), r = p[i].back();

        if(st.size() != 0){
            auto it = st.lower_bound(l);
            if(it != st.end() && *it <= r)return cout << "NO", 0;
        }
        for(auto it : p[i])st.insert(it);
        d[i] = {l, r};
    }
    bool flag = 0;
    for(i = Q; i >= 1; -- i){
        while(true){
            if(e.size() == 0)break;
            auto it = e.lower_bound(d[i].first);
            if(it == e.end() || *it > d[i].second)break;
            if(flag)a[*it] = i;
            else a[*it] = Q, flag = 1;

            e.erase(it);
        }
    }
    cout << "YES" << endl;
    for(i = 1; i <= n; ++ i){
        if(a[i] == 0)a[i] = 1;
        cout << a[i] << " ";
    }
    return 0;
}

/*
5 5
2 3 0 0 3
*/


#include <bits/stdc++.h>

#define pb push_back
#define sz size
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

const ll N = 2e5;
const ll INF = 1e9;

ll a[N + 10], n, i, l, r, Q;
pll d[N + 10];
vector <ll> p[N + 10];

int main(){
    set <ll> e;
    cin >> n >> Q;
    for(i = 1; i <= n; ++ i){
        cin >> a[i];
        if(a[i] == 0)e.insert(i);
        p[a[i]].pb(i);
    }
    set <ll> st;
    for(i = 1; i <= Q; ++ i){
        if(p[i].sz() == 0)l = 1, r = 0;
        else l = p[i].front(), r = p[i].back();

        if(st.size() != 0){
            auto it = st.lower_bound(l);
            if(it != st.end() && *it <= r)return cout << "NO", 0;
        }
        for(auto it : p[i])st.insert(it);
        d[i] = {l, r};
    }
    for(i = Q; i >= 1; -- i){
        while(true){
            if(e.size() == 0)break;
            auto it = e.lower_bound(d[i].first);
            if(it == e.end() || *it > d[i].second)break;
            a[*it] = i;
            e.erase(it);
        }
    }
    cout << "YES" << endl;
    for(i = 1; i <= n; ++ i){
        if(a[i] == 0)a[i] = 1;
        cout << a[i] << " ";
    }
    return 0;
}

/*
*/


#include <bits/stdc++.h>

#define pb push_back
#define sz size
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

const ll N = 2e5;
const ll INF = 1e9;

ll a[N + 10], n, i, l, r, Q;
pll d[N + 10];
vector <ll> p[N + 10];

void check(){
    for(i = 1; i <= Q; ++ i)p[i].clear();
    for(i = 1; i <= n; ++ i)p[a[i]].pb(i);

    set <ll> st;
    for(i = 1; i <= Q; ++ i){
        if(p[i].sz() == 0)l = 1, r = 0;
        else l = p[i].front(), r = p[i].back();
        if(st.size() != 0){
            auto it = st.lower_bound(l);
            if(it != st.end() && *it <= r){cout << "NO";exit(0);}
        }

        for(auto it : p[i])st.insert(it);
        d[i] = {l, r};
    }
}

int main(){
    set <ll> e;
    cin >> n >> Q;
    for(i = 1; i <= n; ++ i){
        cin >> a[i];
        if(a[i] == 0)e.insert(i);
    }
    check();
    bool flag = p[Q].size();
    for(i = Q; i >= 1; -- i){
        //cout << i << " " << d[i].first << " " << d[i].second << endl;
        while(true){
            //cout << "i = " << i << endl;
            if(e.size() == 0)break;
            auto it = e.lower_bound(d[i].first);
            if(it == e.end() || *it > d[i].second)break;
            //cout << "true" << endl;
            if(flag)a[*it] = i;
            else a[*it] = Q, flag = 1;

            e.erase(it);
        }
    }
    check();

    for(i = 1; i <= n; ++ i){
        if(a[i] == 0){
            if(flag == 0)flag = 1, a[i] = Q;
            else a[i] = 1;
        }
    }
    //cout << "true" << endl;
    check();
    cout << "YES" << endl;
    for(i = 1; i <= n; ++ i)cout << a[i] << " ";
    return 0;
}

/*
7 10
5 0 0 5 3 0 3
*/


#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const int N = 100010, M = 1000010, INF = 0x3f3f3f3f;

PII a[1000010];

int main(){
//	freopen("in.txt", "r", stdin);
	int cas; cin >> cas;
	while (cas --){
		int n; cin >> n;
		VI v;
		VI res;
		map<int, int> mp;
		int now = 1;
		for (int i = 2; i <= n / i; i ++){
			while (n % i == 0){
				now *= i;
				n /= i;
				if (mp[now] == 0) {
					mp[now] = 1;
					res.push_back(now);
					now = 1;
				}
			}
		}
	//	for (int i = 0; i < res.size(); i ++) cout << res[i] << " "; cout << endl;
		if (n > 1 && mp[n * now] == 0) {
			res.push_back(n * now);
		} else if (n > 1 && mp[n * now] > 0) {
			sort(res.begin(), res.end());
			int len = res.size() - 1;
			res[len] *= n * now;
		}
	//	for (int i = 0; i < res.size(); i ++) cout << res[i] << " "; cout << endl;
		if (res.size() < 3) puts("NO");
		else {
			for (int i = 3; i < res.size(); i++)
				res[2] = res[2] * res[i];
			puts("YES");
			sort(res.begin(), res.end());
			cout << res[0] << " " << res[1] << " " << res[2] << endl;
		}
	}

	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const int N = 100010, M = 1000010, INF = 0x3f3f3f3f;

PII a[1000010];

int main(){
//	freopen("in.txt", "r", stdin);
	int cas; cin >> cas;
	while (cas --){
		int n; cin >> n;
		VI v;
		VI res;
		map<int, int> mp;
		int now = 1;
		for (int i = 2; i <= n / i; i ++){
			while (n % i == 0){
				now *= i;
				n /= i;
				if (mp[now] == 0) {
					mp[now] = 1;
					res.push_back(now);
					now = 1;
				}
			}
		}
	//	for (int i = 0; i < res.size(); i ++) cout << res[i] << " "; cout << endl;
		if (n > 1 && mp[n * now] == 0) {
			res.push_back(n * now);
		} else if (n > 1 && mp[n * now] > 0) {
			sort(res.begin(), res.end());
			int len = res.size() - 1;
			res[len] *= n * now;
		}
		//for (int i = 0; i < res.size(); i ++) cout << res[i] << " "; cout << endl;
		if (res.size() < 3) puts("NO");
		else {
			for (int i = 3; i < res.size(); i++)
				res[2] = res[2] * res[i];
			puts("YES");
		//	sort(res.begin(), res.end());
			cout << res[0] << " " << res[1] << " " << res[2] << endl;
		}
	}

	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const int N = 100010, M = 1000010, INF = 0x3f3f3f3f;

PII a[1000010];

int main(){
///	freopen("in.txt", "r", stdin);
	int cas; cin >> cas;
	while (cas --){
		int n; cin >> n;
		VI v;
		VI res;
		map<int, int> mp;
		int now = 1;
		for (int i = 2; i <= n / i; i ++){
			while (n % i == 0){
				now *= i;
				n /= i;
				if (mp[now] == 0) {
					mp[now] = 1;
					res.push_back(now);
					now = 1;
				}
			}
		}
	//	for (int i = 0; i < res.size(); i ++) cout << res[i] << " "; cout << endl;
		if (n > 1 && mp[n] == 0) {
			res.push_back(n * now);
		} else if (n > 1 && mp[n] > 0) {
			sort(res.begin(), res.end());
			int len = res.size() - 1;
			res[len] *= n * now;
		}
	//	for (int i = 0; i < res.size(); i ++) cout << res[i] << " "; cout << endl;
		if (res.size() < 3) puts("NO");
		else {
			for (int i = 3; i < res.size(); i++)
				res[2] = res[2] * res[i];
			puts("YES");
			sort(res.begin(), res.end());
			cout << res[0] << " " << res[1] << " " << res[2] << endl;
		}
	}

	return 0;
}


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

using namespace std;

const int N = 100010, INF = 0x3f3f3f3f;

void solve(){
	int x; scanf("%d", &x);
	for (int a = 2; a * (a + 1) * (a + 2) <= x; a ++){
		if (x % a) continue;
		for (int b = a + 1; a * b * (b + 1) <= x; b ++){
			if (x % (a * b) == 0) {
				puts("YES");
				cout << a << " " << b << " " << x / a / b << endl;
				return;
			}
		}
	}
	puts("NO");
}

int main(){
	int cas; cin >> cas;
	while (cas --) solve();
	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const int N = 100010, M = 1000010, INF = 0x3f3f3f3f;

PII a[1000010];

int main(){
//	freopen("in.txt", "r", stdin);
	int cas; cin >> cas;
	while (cas --){
		int n; cin >> n;
		VI v;
		VI res;
		map<int, int> mp;
		int now = 1;
		for (int i = 2; i <= n / i; i ++){
			while (n % i == 0){
				now *= i;
				n /= i;
				if (mp[now] == 0) {
					mp[now] = 1;
					res.push_back(now);
					now = 1;
				}
			}
		}
		if (n > 1 && mp[n] == 0) {
			res.push_back(n);
		}
		if (res.size() < 3) puts("NO");
		else {
			for (int i = 3; i < res.size(); i++)
				res[2] = res[2] * res[i];
			puts("YES");
			cout << res[0] << " " << res[1] << " " << res[2] << endl;
		}
	}

	return 0;
}


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

using namespace std;

const int N = 100010, INF = 0x3f3f3f3f;

void solve(){
	int x; scanf("%d", &x);
	for (int a = 2; a * (a + 1) * (a + 2) <= x; a ++){
		if (n % a) continue;
		for (int b = a + 1; a * b * (b + 1) <= x; b ++){
			if (n % (a * b) == 0) {
				puts("YES");
				cout << a << " " << b << " " << n / a / b << endl;
				return;
			}
		}
	}
	puts("NO");
}

int main(){
	int cas; cin >> cas;
	while (cas --) solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e9 + 5;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;

			for (int i = 0; i < 3; i++)
			{
				cout << dila[i].first << " ";
			}
			cout << endl;
		}
		if (dila.size() == 2)
		{
			int mul = 1;
			for (auto h : dila)
			{
				mul *= h.first;
			}

			int third = n / mul;

			if (third == dila[0].first or third == dila[1].first)
			{
				cout << "NO" << endl;
			}
			else
			{
				cout << "YES" << endl;
				cout << dila[0].first << " " << dila[1].first << " " << third << endl;
			}
		}
		if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				if (b.second >= 6)
				{
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << b.first*b.first*b.first << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 + 5;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;

			for (int i = 0; i < 3; i++)
			{
				cout << dila[i].first << " ";
			}
			cout << endl;
		}
		else if (dila.size() == 2)
		{
			int mul = 1;
			for (auto h : dila)
			{
				mul *= h.first;
			}

			int third = n / mul;

			if (third == dila[0].first && third == dila[1].first)
			{
				cout << "NO" << endl;
			}
			else
			{
				cout << "YES" << endl;
				cout << dila[0].first << " " << dila[1].first << " " << third << endl;
			}
		}
		else if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				if (b.second >= 6)
				{
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << b.first*b.first*b.first << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}