#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,max,indmax;
    scanf("%d",&n);
    int tab[n];
    scanf("%d",&tab[0]);
    for (i=1;i<n;i++)
       scanf("%d",&tab[i]);
    indmax=0;
    max=tab[0];
     for (i=1;i<n;i++)
     {
         if (max <tab[i])
         {max=tab[i];
          indmax=i;}
     }
     max=0;
     for (i=0;i<n;i++)
     {
         if ((max <tab[i])&& (i!=indmax))
         {max=tab[i];
          }
     }
     printf("%d %d",indmax+1,max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int arr[1000];
    int i;
    int n;
    int maxm=-999999;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=0;i<n;i++)
    {
        if(arr[i]>maxm)
        {
            maxm=arr[i];
        }
    }
    for(i=0;i<n;i++)
    {
        if(maxm==arr[i])
        {
            arr[i]=-999999;
            maxm=-999999;
            break;
        }
    }
    printf("%d ",i+1);
    for(i=0;i<n;i++)
    {
        if(arr[i]>maxm)
        {
            maxm=arr[i];
        }
    }
    printf("%d",maxm);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
    int n;
    scanf("%d",&n);
    int arr[n];
    int i;
    int maximum=0,index;
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        if(arr[i]>maximum)
        {
            maximum=arr[i];
            index=i;
        }
    }
    maximum=0;
    for(i=0;i<n;i++)
    {
        if(i!=index &&arr[i]>maximum)
        {
            maximum=arr[i];
        }
    }
    printf("%d %d",index+1,maximum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main (int argc, char * argv[]){

    long numBidders = 0;
    scanf("%ld", &numBidders);

    int count = 1;
    int curMax = -1;
    int secMax = -2;
    int curMaxIndex = -1;
    while (count <= numBidders){
        int nextBidder;
        scanf("%d", &nextBidder);
        if (nextBidder >= curMax){
            curMaxIndex = count;
            secMax = curMax;
            curMax = nextBidder;
        } else if (nextBidder >= secMax){
            secMax = nextBidder;
        }
        ++count;
    }

    printf("%d %d", curMaxIndex, secMax);
    printf("\n");

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(){
    int n, i;
    int first, second, winner;
    int * bids;
    scanf("%d",&n);
    bids = (int *) malloc(sizeof(int) * n);
    for(i = 0; i < n; ++i){
        scanf("%d",&bids[i]);
    }
    if(bids[0] < bids[1]){
        winner = 1;
        first = bids[1];
        second = bids[0];
    }else
    {
        winner = 0;
        first = bids[0];
        second = bids[1];
    }
    for(i = 2; i < n; ++i){
        if(bids[i] > first){
            winner = i;
            second = first;
            first =  bids[i];
        }else if(bids[i] > second){
            second = bids[i];
        }
    }
    printf("%d %d\n",winner +1, second);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    int temp;
    int i,j;
    scanf("%d",&n);
    int arr1[1100];
    int arr2[1100];
    for(i=0;i<n;i++){
        scanf("%d",&arr1[i]);
    }
    for(i=0;i<n;i++){
        arr2[i]=i+1;
    }
    for(i=0;i<n;i++){
        for(j=0;j<n-1-i;j++){
            if(arr1[j]<arr1[j+1]){
                temp=arr1[j];
                arr1[j]=arr1[j+1];
                arr1[j+1]=temp;
                temp=arr2[j];
                arr2[j]=arr2[j+1];
                arr2[j+1]=temp;
            }
        }
    }
    printf("%d ",arr2[0]);
    printf("%d",arr1[1]);
    return 0;
}


#include <stdio.h>

int main()
{
    int i,n,a,b[1000],max=0,secmax=0,num;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(b[i]>max)
        {
            max=b[i];
            num=i;
        }
    }
    for(i=1;i<=n;i++)
    {
        if((b[i]>secmax)&&(b[i]!=max))
        {
            secmax=b[i];
        }
    }
    printf("%d %d",num,secmax);
    return 0;
}


#include<stdio.h>
int main()
{
	int i,j,n,k;
	scanf("%d",&n);
	int a[n];
	int max=-1,ind=1;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>max)
		{
			max=a[i];
			ind=i+1;
		}
	}
	max=-1;
	for(i=0;i<n;i++)
	{
		if(a[i]>max && i+1 != ind)	max=a[i];
	}
	printf("%d %d\n",ind,max);
	return 0;
}


#include<stdio.h>
int main()
{
	int i,j,n,k;
	scanf("%d",&n);
	int a[n];
	scanf("%d",&k);
	int max=k,pr=k,ind=1;
	for(i=1;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>max)
		{
			pr=max;
			max=a[i];
			ind=i+1;
		}
	}
	if(ind==1)
	{
		max=-1;
		for(i=1;i<n;i++)
		{
			if(a[i]>max)	max=a[i];
		}
		pr=max;
	}
	printf("%d %d\n",ind,pr);
	return 0;
}


#include <stdio.h>

int main(void) {
	int index,n,max,smax,i;
	int a[2000];
	scanf("%d\n",&n);
	max=0;
	for(i=0;i<n;i++)
	{
		scanf("%d ",&a[i]);
		if(a[i]>max)
		{
			smax=max;
			max=a[i];
			index=i+1;
		}
		else if(a[i]>smax)
		{
			smax=a[i];
		}
	}
		printf("%d %d",index,smax);

	// your code goes here
	return 0;
}


#include <stdio.h>

int main(void) {
	int index,n,max,smax,i;
	int a[2000];
	scanf("%d\n",&n);
	max=0;
	for(i=0;i<n;i++)
	{
		scanf("%d ",&a[i]);
		if(a[i]>max)
		{
			smax=max;
			max=a[i];
			index=i+1;
		}
	}
		printf("%d %d",index,smax);

	// your code goes here
	return 0;
}


#include<stdio.h>

int main(){
	int p[1000];
	int n,i,max,tmp,j;
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d",&p[i]);
		if (i==0) {
			max=p[0];
			j=0;
		}
		if (max<p[i]) {
			max=p[i];
			j=i;
		}
	}
	p[j]=0;
	max=p[0];
	for (i=0;i<n;i++){
		if (max<p[i]) max=p[i];
	}
	printf("%d %d\n",j+1,max);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int porovnej(const void *a, const void *b){
    return (-*(int*)a+*(int*)b);

}

int main()
{
    int *pole;
    int *pole2;
    int lidi=0,i=0,pocet=0;
    char z=0;

    scanf("%d",&lidi);
    pole=(int*)malloc(lidi*sizeof(int));
    pole2=(int*)malloc(lidi*sizeof(int));

    while(1){
    scanf("%d%c",&pole[i],&z);
    if(z=='\n') break;
    i++;
    }

    i=0;
      while(i<lidi){
    pole2[i]=pole[i];i++;}
    i=0;
qsort(pole,lidi,sizeof(int),porovnej);

i=0;
    while(i<lidi){
        if(pole2[i]==pole[0]){printf("%d",i+1);}
        i++;
    }
 printf(" %d",pole[1]);
    free(pole);
    free(pole2);
    return 0;
}


/*
USER: Sudipto Chowdhury Dip
*/

#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <utility>

using namespace std;

template< class T > T _abs(T n) { return (n < 0 ? -n : n); }
template< class T > T _max(T a, T b) { return (!(a < b) ? a : b); }
template< class T > T _min(T a, T b) { return (a < b ? a : b); }
template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > void setmax(T &a, T b) { if(a < b) a = b; }
template< class T > void setmin(T &a, T b) { if(b < a) a = b; }

#define SIZE 10000
#define MP(x, y) make_pair(x, y)
#define REV(s, e) reverse(s, e)
#define SET(p) memset(p, -1, sizeof(p))
#define CLR(p) memset(p, 0, sizeof(p))
#define MEM(p, v) memset(p, v, sizeof(p))
#define CPY(d, s) memcpy(d, s, sizeof(s))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define ALL(c) c.begin(), c.end()
#define SIZE(c) (int)c.size()
#define PB(x) push_back(x)
#define ff first
#define ss second
#define i64 __int64
#define ld long double
#define pii pair< int, int >
#define psi pair< string, int >

const double EPS = 1e-9;
const double BIG = 1e19;
const int INF = 0x7f7f7f7f;

int main()
{
    //READ("in.txt");
    //WRITE("out.txt");

    int test, value, max = 0, loc = 0;
    vector <int> v;
    vector <int> :: iterator it;

    cin >> test;

    for( int i = 0; i < test; i++ )
    {
        cin >> value;
        v.push_back(value);
    }

    for( int i = 0; i < v.size(); i++ )
    {
        if( v[i] > max )
        {
            max = v[i];
            loc = i+1;
        }
    }

    sort(v.rbegin(), v.rend());

    cout << loc << " " << v[1] << endl;

    return 0;
}


#include<stdio.h>

int main()
{
    int n,x,Fir=0,Sec=0,i,t;

    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if (x>Fir)
        {
            t=i;
            Sec=Fir;
            Fir=x;
        }
        else if (x>Sec)
            Sec=x;
    }
    printf("%d %d\n",t,Sec);

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int n,max,win;
int a[1010];
int i,j;
int cmp(const void *a, const void *b)
{
    return *(int *) b- *(int *) a;
}
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>max)
        {
            max=a[i];
            win=i;
        }
    }
    qsort(a,n+1,sizeof(a[0]),cmp);
    printf("%d %d",win,a[1]);
    return 0;
}


#include<stdio.h>
//#include<conio.h>

int compare(const void* a,const void* b)
{
    return (*(int*)b - *(int*)a);
}
int main()
{
    int a,i,l;
    scanf("%d",&a);
    int arr[a];
    int arr1[10000];
    for(i=0;i<a;i++)
    {
                    l = i;
                    scanf("%d",&arr[i]);
                    arr1[arr[i]] = l+1;
    }

    qsort(arr,a,sizeof(int),compare);
    printf("%d %d",arr1[arr[0]],arr[1]);

    //getch();
    return 0;
}


#include<stdio.h>
int main()
{
    int n,a[100],i,max=0,p,m;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>max){
            p=max;
            max=a[i];
            m=i+1;
        }
    }
    printf("%d %d",m,p);
    return 0;
}


#include<stdio.h>
int main()
{
    long int a[100],max=0,p;
    int n,i,j,m;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%ld",&a[i]);
        if(a[i]>max){
            p=max;
            max=a[i];
            m=i+1;
        }
        if((m==1)&&(i!=0)&&(a[i]>p))
            p=a[i];
    }
    printf("%d %ld",m,p);
    return 0;
}


#include<stdio.h>
#include<conio.h>

int main()
{
    int n,i,m,a,max=0,p=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a>max){
            if(max>p)
                p=max;
            max=a;
            m=i+1;
        }
        else if(a>p)
            p=a;
    }
    printf("%d %d",m,p);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,a[1000],i,max=0,p,m;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>max){
            p=max;
            max=a[i];
            m=i+1;
        }
    }
    printf("%d %d",m,p);
    return 0;
}


#include<stdio.h>
#include<conio.h>

int main()
{
    long int a[100],max=0,p;
    int n,i,j,m;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%ld",&a[i]);
        if(a[i]>max){
            //p=max;
            max=a[i];
            m=i+1;
        }
    }
    for(i=n-1;i>0;i--)
        for(j=0;j<i;j++)
            if(a[j]<a[j+1]){
                p=a[j];    a[j]=a[j+1];    a[j+1]=p;
            }
    printf("%d %ld",m,a[1]);
    return 0;
}


#include<stdio.h>

int main()
{
    int ara[10000],n,i,max1,pos,j,t;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&ara[i]);
    }
    max1=ara[0];
    for(i=1;i<n;i++){
        if(ara[i]>max1){
            max1=ara[i];
            pos=i+1;
        }
    }
    if(max1==ara[0]){
        pos=1;
    }
    for(i=1;i<n;i++){
        for(j=n-1;j>=i;j--){
            if(ara[j-1]<ara[j]){
                t=ara[j-1];
                ara[j-1]=ara[j];
                ara[j]=t;
            }
        }
    }
    printf("%d %d\n",pos,ara[1]);
    return 0;
}


#include <stdio.h>

int maxIndex(int *v, int n){
    int i;
    int max = v[0];
    int index = 0;
    for(i=0;i<n;i++) if(max<v[i]) index = i;
    v[index] = -1;
    return index;
}

int maxSum(int *v, int n, int index){
    int i, max;
    max = v[0];
    for(i=0;i<n;i++) if(max<v[i]) max = v[i];
    return max;
}

int main(){
    int n, i;
    scanf("%d", &n);
    int p[n];
    for(i=0;i<n;i++) scanf("%d", &p[i]);
    i = maxIndex(p, n);
    printf("%d %d", i+1, maxSum(p, n, i));
    return 0;
}


#include <stdio.h>

int maxIndex(int *v, int n){
    int i;
    int max = v[0];
    int index = 0;
    for(i=0;i<n;i++) if(max<v[i]){index = i; max = v[i];}
    v[index] = -1;
    return index;
}

int maxSum(int *v, int n, int index){
    int i, max;
    max = v[0];
    for(i=0;i<n;i++) if(max<v[i]) max = v[i];
    return max;
}

int main(){
    int n, i, l;
    scanf("%d", &n);
    int p[n];
    for(i=0;i<n;i++) scanf("%d", &p[i]);
    l = maxIndex(p, n);
    printf("%d %d", l+1, maxSum(p, n, l));
    return 0;
}


#include <stdio.h>

int maxIndex(int *v, int n){
    int i;
    int max = v[0];
    int index;
    for(i=0;i<n;i++){
        if(max<v[i]) index = i;
    }
    v[index] = -1;
    return index;
}

int maxSum(int *v, int n, int index){
    int i, max;
    max = v[0];
    for(i=0;i<n;i++){
        if(max<v[i]) max = v[i];
    }
    return max;
}

int main(){

    int n, i;
    scanf("%d", &n);

    int p[n];
    for(i=0;i<n;i++) scanf("%d", &p[i]);
    i = maxIndex(p, n);
    printf("%d %d", i+1, maxSum(p, n, i));

    return 0;
}


#include <stdio.h>

int maxIndex(int *v, int n){
    int i;
    int max = v[0];
    int index;
    for(i=0;i<n;i++){
        if(max<v[i]) index = i;
    }
    v[index] = -1;
    return index;
}

int maxSum(int *v, int n, int index){
    int i, max;
    max = v[0];
    for(i=0;i<n;i++){
        if(max<v[i]) max = v[i];
    }
    return max;
}

int main(){

    int n, i;
    scanf("%d", &n);

    int p[n];
    for(i=0;i<n;i++) scanf("%d ", &p[i]);
    i = maxIndex(p, n);
    printf("%d %d", i+1, maxSum(p, n, i));

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
typedef struct {
	int price;
	int id;
} Bidder;

int mycomp(const void *a, const void *b)
{
	int p1 = ((Bidder*)a)->price;
	int p2 = ((Bidder*)b)->price;
	return p1 < p2;
}

int main(void) {
	int n,i,j;
	Bidder bidder[1000];
	scanf("%d",&n);
	for (i = 0; i < n; i++)
	{
		int p;
		scanf("%d",&p);
		bidder[i].price = p;
		bidder[i].id = i+1;
	}
	qsort(bidder,n,sizeof(Bidder),mycomp);
	/*
	for (i = 0; i < n; i++)
	for (j = n-1; j > i; j--)
		if (bidder[j].price > bidder[j-1].price)
		{
			Bidder temp = bidder[j-1];
			bidder[j-1] = bidder[j];
			bidder[j] = temp;
		}
	*/
	printf("%d %d\n",bidder[0].id,bidder[1].price);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
typedef struct {
	int price;
	int id;
} Bidder;

int mycomp(const void *a, const void *b)
{
	int p1 = ((Bidder*)a)->price;
	int p2 = ((Bidder*)b)->price;
	return p1 < p2;
}

int main(void) {
	int n,i,j;
	Bidder bidder[1000];
	scanf("%d",&n);
	for (i = 0; i < n; i++)
	{
		int p;
		scanf("%d",&p);
		bidder[i].price = p;
		bidder[i].id = i+1;
	}
	//qsort(bidder,n,sizeof(Bidder),mycomp);

	for (i = 0; i < n; i++)
	for (j = n-1; j > i; j--)
		if (bidder[j].price > bidder[j-1].price)
		{
			Bidder temp = bidder[j-1];
			bidder[j-1] = bidder[j];
			bidder[j] = temp;
		}

	printf("%d %d\n",bidder[0].id,bidder[1].price);

	return 0;
}


#include <stdio.h>

int main(void) {
    int t,i=0,j=0,max=0,second=0,temp=0;
    scanf("%d",&t);
    int b[t];
    for(i=0;i<t;i++){
        scanf("%d",&b[i]);
    }
    max=b[0];
    second=b[1];
    if(max<second){
        temp=max;
        max=second;
        second=temp;
    }
    for(i=2;i<t;i++){
        if(max<b[i]){
            second=max;
            max=b[i];
        }
        if(max>b[i] && second<b[i]){
            second=b[i];
        }
    }
    i=0;
    while(max!=b[i]){
        i++;
    }
    printf("%d %d",(i+1),second);
    // your code goes here
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,max=0,maxindex,n;
    scanf("%d",&n);
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        if(arr[i]>max)
        {
            max=arr[i];
            maxindex=i;
        }
    }
    max=0;
    for(i=0;i<n;i++)
    {
        if(i!=maxindex && arr[i]>max)
        {
            max=arr[i];
        }
    }
    printf("%d %d",maxindex+1,max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    int n,m,i,j,a,b,ans;
    int pos;
    int arr[1000];
    scanf("%d", &n);
    for(i=0; i<n; i++)
             scanf("%d", &arr[i]);
    if(arr[0] > arr[1])
    {
              ans=arr[1];
              pos=0;
    }
    else
    {
              ans=arr[0];
              pos=1;
    }
    for(i=2; i<n; i++)
    {
             if(arr[i]>arr[pos])
             {
                   ans=arr[pos];
                   pos=i;
             }
             else
                   if(arr[i]>ans)
                          ans=arr[i];
    }
pos=pos+1;
printf("%d %d",pos,ans);
return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    int n,m,i,j,a,b,ans;
    int pos;
    int arr[1000];
    scanf("%d", &n);
    for(i=0; i<n; i++)
             scanf("%d", &arr[i]);
    if(arr[0] > arr[1])
    {
              ans=arr[1];
              pos=0;
    }
    else
    {
              ans=arr[0];
              pos=1;
    }
    for(i=2; i<n; i++)
    {
             if(arr[i]>arr[pos])
             {
                   ans=arr[pos];
                   pos=i;
             }
             else
                   if(arr[i]>ans)
                          ans=arr[i];
    }
pos=pos+1;
printf("%d %d",pos,ans);
}


#include <stdio.h>
#include <stdlib.h>

typedef struct bb
{
	int price;
	int num;
} BB;

int compare(const void *data1, const void *data2)
{
	BB *ptr1 = (BB *)data1;
	BB *ptr2 = (BB *)data2;

	if (ptr1->price > ptr2->price)
		return -1;
	else if (ptr1->price < ptr2->price)
		return 1;
	else
		return 0;
}

int main()
{
	int n;
	BB bidder[1000];
	int	i;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &bidder[i].price);
		bidder[i].num = i + 1;
	}
	qsort(bidder, n, sizeof(BB), compare);

	printf("%d ", bidder[0].num);
	printf("%d", bidder[1].price);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#define len 100000

int main()
{
    int n,i=0,p[1000],j=0,max,flag=1,temp,k,c=0;
    scanf("%i",&n);
    while(i<=n-1)
    {
        scanf("%i",&p[i]);
        i++;
    }
    for(j; j<=n-1; j++)
    {
        for(k=0; k<=n-1; k++)
        {
            if(p[j]<p[k])
            {
                flag=0;
                break;
            }
            if(p[k]<=p[j] && k==n-1)
            {
                flag=1;
                break;
            }
        }
        if(flag==1 && c==0){
            printf("%i",j+1);
            p[j]=0;
            j=-1;
            c++;
        }
        else if(flag==1 && c==1){
            printf(" %i",p[j]);
            break;
        }
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int n,i,a[1000],high,max=0,secmax=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(max<a[i])
        {
            max=a[i];
            high=i;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(secmax<a[i] && a[i]!=max)
            secmax=a[i];
    }
    printf("%d %d",high,secmax);

    return 0;
}


#include <stdio.h>

int main(void) {
    // your code goes here
    int n,i;
    scanf("%d",&n);
    int arr[n];
    int max = -1;
    int index = 1;
    for(i=0;i<n;i++){

        scanf("%d",&arr[i]);
        if(max <= arr[i]){
            max = arr[i];
            index = i;
        }
    }
    arr[index] = -1;
    int max2 = -1;

    for(i=0;i<n;i++){
        if(max2 < arr[i])
            max2 = arr[i];
    }
    printf("%d %d\n",index+1,max2);
    return 0;
}


#include <stdio.h>
int main()
{  int tab[2000],i,max=0,posmax=0,index=-1,n;
scanf("%d",&n);
for(i=0;i<n;i++)
  {
  scanf("%d",&tab[i]);
  if (tab[i]>max) { max=tab[i];posmax=i+1;}
   }
while(max-- && index==-1)
 for(i=0;i<n;i++)
   if(tab[i]==max) {index=i;break;}

printf("%d %d",posmax,tab[index]);
return 0;
}


#include <stdio.h>
int main()
{  int tab[2000],i,max=0,posmax=0,index=-1,n;
scanf("%d",&n);
for(i=0;i<n;i++)
  {
  scanf("%d",&tab[i]);
  if (tab[i]>max) { max=tab[i];posmax=i+1;}
   }
while(max-- && index==-1)
 for(i=0;i<n;i++)
   if(tab[i]==max) {index=i;break;}

printf("%d %d",posmax,tab[index]);
}


#include <stdio.h>
int main() {
  int n, maxi, max = 0, max2 = 0, bid;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &bid);
    if (bid > max) {
      max2 = max;
      max = bid;
      maxi = i;
    } else if (bid > max2)
      max2 = bid;
  }
  printf("%d %d\n", maxi, max2);
  return 0;
}


#include <stdio.h>
int main() {
  int n, maxi, max = 0, max2 = 0, bid, i;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &bid);
    if (bid > max) {
      max2 = max;
      max = bid;
      maxi = i;
    } else if (bid > max2)
      max2 = bid;
  }
  printf("%d %d\n", maxi, max2);
  return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,a[100001],max=0,I,i,j,max2=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);

        if(a[i]>max){max=a[i];I=i;}
    }

    for(i=0;i<n;i++)
    {
        if(a[i]>max2 && a[i]!=max){max2=a[i];}
    }

    printf("%d %d",I+1,max2);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n,i,maximum,temp,x=0;
    scanf("%d",&n);
    if(n<2||n>1000)
    {
        main();
    }
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    maximum=arr[0];
    for(i=0;i<n;i++)
    {
        if(arr[i]>maximum)
        {
            maximum=arr[i];
            x++;
            temp=i;
        }
    }
    if(x==0)
    {
        temp=0;
    }
    if(temp==0)
    {
        maximum=arr[1];
    }
    else
    {
        maximum=arr[0];
    }
    for(i=0;i<n;i++)
    {
        if(i==temp)
        {
            continue;
        }
        else if(arr[i]>maximum)
        {
            maximum=arr[i];
        }
    }
    printf("%d %d",temp+1,maximum);
    return 0;
}


#include<stdio.h>
int main()
{

    int n,i;
    scanf("%d",&n);

    int a[n];
    int maxi=1,H=-1,SH=-2;

    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);

        if(a[i]>H && a[i]>SH)
        {
            SH=H;
            H=a[i];
            maxi=i+1;
        }
        else if(a[i]<H && a[i]>SH)
        {
            SH=a[i];
        }

    }

    printf("%d %d",maxi,SH);

    return 0;
}


#include<stdio.h>

    int main()
    {
        int n,i,j;
        long max=0,max2=0;
        scanf("%d",&n);
        long arr[n];
        for(i=0;i<n;i++)
        {
            scanf("%ld",&arr[i]);
            if(arr[i]>max)
            {j=i+1;
            max=arr[i];
            }
        }
            for(i=0;i<n;i++)
        {

            if(arr[i]>max2&&i!=j-1)
            {
            max2=arr[i];
            }
        }
        printf("%d %ld",j,max2);
        return 0;

    }


#include <stdio.h>

int  mian ()
{
    int n, r;
    int i, j;
    int winner;
    int max = 0, second = 0;

    scanf ("%d", &n);

    for (i=0; i<n; i++)
    {
        scanf ("%d", &r);
        if (r > max)
        {
            second = max;
            max = r ;
            winner = i+1;
        }
        else if (r > second)
        {
            second = r;
        }
    }
    printf("%d %d", winner, second);
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int n,p;
char ans[1002],inp[1002];
bool check(int pos){
	 if (pos > 0 && ans[pos-1] == ans[pos])
		return true;
     if (pos > 1 && ans[pos-2] == ans[pos])
		return true;
	 return false;
}
bool possible(int pos, int ok)
{
    if (pos == n)
		return ok;
    int start = ok ? 0 : inp[pos] - 'a';
    int i;
    for (i = start ; i < p; i++)
    {
        ans[pos] = i + 'a' ;
		if(!check(pos))
			if (possible(pos+1 , ok | ( i > start )))
				return true;
    }
    return false;

}
int main()
{
//	freopen("f.txt","r",stdin);
	scanf("%d%d",&n,&p);
	scanf("%s",inp);
	bool ok = 0 ;
	int i ;
	if(possible(0,0)){
      ans[n] = '\0';
      printf("%s\n",ans);
	}
	else
		printf("NO\n");
    return 0;
}


#pragma comment(linker, "/STACK:64777216")
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<memory.h>
#include<ctime>
#include<cassert>

#define pb push_back
#define sz(a) (int)a.size()
#define bs binary_search
#define np next_permutation
#define mp make_pair
#define all(a) a.begin(),a.end()
#define read(a) scanf("%d", &a)
#define writeln(a) printf("%d\n", a);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forv(i, v) for (int i = 0; i < sz(v); ++i)
#define forsint(it, s) for (set<int>::iterator it = s.begin(); it != s.end(); ++it)
#define _(a, b) memset(a, b, sizeof a)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

template<class T> inline T sqr(T x) { return x * x; }

const double pi = acos(-1.0), eps = 1e-9, e = exp(1.0);
const int INF = 1000 * 1000 * 1000 + 5, MAXN = 100005, MOD = 1000000007;
const ll INFL = 1e+18;

void prepare(string s) {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
#else
    if (sz(s) != 0) {
        freopen((s + ".in").c_str(), "r", stdin);
        freopen((s + ".out").c_str(), "w", stdout);
    }
#endif
}

int n, p;
string s;

char alpha[26];

void solve()
{
    cin >> n >> p >> s;
	for (char c = 'a'; c <= 'z'; c++)
		alpha[c-'a'] = c;
	char gr = alpha[p-1];
	if (n == 1) {
		s[0]++;
		if (s[0] <= gr)
			cout << s;
		else
			cout << "NO";
	}
	if (n == 2) {
		char start = s[1];
		start++;
		for (char c = s[0]; c <= gr; c++) {
			if (c != s[0])
				start = 'a';
			for (char d = start; d <= gr; d++)
				if (d != c) {
					cout << c << d;
					return;
				}
		}
		cout << "NO";
	}
	if (n >= 3) {
		char start, A, B;
		bool f = false;
		for (int i = sz(s)-1; i >= 2; i--) {
			start = s[i], A = s[i-1], B = s[i-2];
			start++;
			for (char c = start; c <= gr; c++)
				if (c != A && c != B) {
					s[i] = c;
					f = true;
					break;
				}
			if (f) {
				for (int j = i + 1; j < sz(s); j++)
					for (char c = 'a'; c <= gr; c++)
						if (c != s[j-1] && c != s[j-2]) {
							s[j] = c;
							break;
						}
				cout << s;
				break;
			}
		}
		if (!f)
			cout << "NO";
	}
}

int main()
{
    prepare("");

    solve();

    return 0;
}


#pragma comment(linker, "/STACK:64777216")
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<memory.h>
#include<ctime>
#include<cassert>

#define pb push_back
#define sz(a) (int)a.size()
#define bs binary_search
#define np next_permutation
#define mp make_pair
#define all(a) a.begin(),a.end()
#define read(a) scanf("%d", &a)
#define writeln(a) printf("%d\n", a);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forv(i, v) for (int i = 0; i < sz(v); ++i)
#define forsint(it, s) for (set<int>::iterator it = s.begin(); it != s.end(); ++it)
#define _(a, b) memset(a, b, sizeof a)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

template<class T> inline T sqr(T x) { return x * x; }

const double pi = acos(-1.0), eps = 1e-9, e = exp(1.0);
const int INF = 1000 * 1000 * 1000 + 5, MAXN = 100005, MOD = 1000000007;
const ll INFL = 1e+18;

void prepare(string s) {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
#else
    if (sz(s) != 0) {
        freopen((s + ".in").c_str(), "r", stdin);
        freopen((s + ".out").c_str(), "w", stdout);
    }
#endif
}

int n, p;
string s;

char alpha[26];

void solve()
{
    cin >> n >> p >> s;
	for (char c = 'a'; c <= 'z'; c++)
		alpha[c-'a'] = c;
	char gr = alpha[p-1];
	if (n == 1) {
		s[0]++;
		if (s[0] <= gr)
			cout << s;
		else
			cout << "NO";
	}
	if (n == 2) {
		char start = s[1];
		start++;
		for (char c = s[0]; c <= gr; c++) {
			if (c != s[0])
				start = 'a';
			for (char d = start; d <= gr; d++)
				if (d != c) {
					cout << c << d;
					return;
				}
		}
		cout << "NO";
	}
	if (n >= 3) {
		char start, A, B;
		bool f = false;
		for (int i = sz(s)-1; i >= 0; i--) {
			start = s[i];
			if (i >= 2)
				A = s[i-1], B = s[i-2];
			if (i == 1)
				A = s[i-1];
			start++;
			if (i >= 2) {
				for (char c = start; c <= gr; c++)
					if (c != A && c != B) {
						s[i] = c;
						f = true;
						break;
					}
			}
			if (i == 1) {
				for (char c = start; c <= gr; c++)
					if (c != A) {
						s[i] = c;
						f = true;
						break;
					}
			}
			if (i == 0) {
				f = true;
				s[i]++;
				if (s[i] > gr) {
					cout << "NO";
					return;
				}
			}
			if (f) {
				for (int j = i + 1; j < sz(s); j++)
					for (char c = 'a'; c <= gr; c++)
						if (j >= 2) {
							if (c != s[j-1] && c != s[j-2]) {
								s[j] = c;
								break;
							}
						}
						else {
							if (c != s[j-1]) {
								s[j] = c;
								break;
							}
						}
				cout << s;
				break;
			}
		}
		if (!f)
			cout << "NO";
	}
}

int main()
{
    prepare("");

    solve();

    return 0;
}


#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <set>
#include <map>
#include <math.h>
#include<vector>
using namespace std;

int n,k;
char s[100005];
void input(){
	scanf("%d%d",&n,&k);
	int i;
	getchar();
	for(i=0;i<n;i++){
		cin>>s[i];
	}
}

char getOKLetter(int position){

	char i;
	for(i=s[position]+1;i<='a'+k-1;i++){
		if(position>=2){
			if( (i != s[position-1]) && (i != s[position - 2])){
				return i;
			}
		}else if(position == 1){
			if( (i != s[position-1])){
				return i;
			}
		}else if(position == 0){
			return i;
		}
	}

	return 0;
}

void process(){

	int i;
	int modifyPosition;
	for(i=n-1;i>=0;i--){
		char temp = getOKLetter(i);
		if(temp != 0){
			s[i] = temp;
			modifyPosition = i;
			break;
		}
	}

	if(i == -1){
		cout<<"NO"<<endl;
		return ;
	}

	//得到点往后修正
	for(i=modifyPosition+1;i<n;i++){
		s[i] = 'a' - 1;
		s[i] =  getOKLetter(i);
	}

	for(i=0;i<n;i++){
		cout<<s[i];
	}

}

int main(){
	input();
	process();
	return 0;
}


#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <set>
#include <map>
#include <math.h>
#include<vector>
using namespace std;

int n,k;
char s[100005];
void input(){
	scanf("%d%d",&n,&k);
	int i;
	getchar();
	for(i=0;i<n;i++){
		cin>>s[i];
	}
}

char getOKLetter(int position){

	char i;
	for(i=s[position]+1;i<='a'+k-1;i++){
		if(position>=2){
			if( (i != s[position-1]) && (i != s[position - 2])){
				return i;
			}
		}else if(position == 1){
			if( (i != s[position-1])){
				return i;
			}
		}else if(position == 0){
			return i;
		}
	}

	return 0;
}

void process(){

	int i;
	int modifyPosition;
	for(i=n-1;i>=0;i--){
		char temp = getOKLetter(i);
		if(temp != 0){
			s[i] = temp;
			modifyPosition = i;
			break;
		}
	}

	if(i == -1){
		cout<<"NO"<<endl;
		return ;
	}

	//得到点往后修正
	for(i=modifyPosition+1;i<n;i++){
		s[i] = 'a' - 1;
		char temp = getOKLetter(i);
		if(temp != 0){
			s[i] = temp;
		}
	}

	for(i=0;i<n;i++){
		cout<<s[i];
	}

}

int main(){
	input();
	process();
	return 0;
}


#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <set>
#include <map>
#include <math.h>
#include<vector>
using namespace std;

int n,k;
char s[100005];
void input(){
	scanf("%d%d",&n,&k);
	int i;
	getchar();
	for(i=0;i<n;i++){
		scanf("%c",&s[i]);
	}
}

char getOKLetter(int position){

	char i;
	for(i=s[position]+1;i<='a'+k-1;i++){
		if(position>=2){
			if( (i != s[position-1]) && (i != s[position - 2])){
				return i;
			}
		}else if(position == 1){
			if( (i != s[position-1])){
				return i;
			}
		}else if(position == 0){
			return i;
		}
	}

	return 0;
}

void process(){

	int i;
	int modifyPosition;
	for(i=n-1;i>=0;i--){
		char temp = getOKLetter(i);
		if(temp != 0){
			s[i] = temp;
			modifyPosition = i;
			break;
		}
	}

	if(i == -1){
		printf("NO\n");
		return ;
	}

	//得到点往后修正
	for(i=modifyPosition+1;i<n;i++){
		s[i] = 'a' - 1;
		char temp = getOKLetter(i);
		if(temp != 0){
			s[i] = temp;
		}
	}

	for(i=0;i<n;i++){
		printf("%c",s[i]);
	}

}

int main(){
	input();
	process();
	return 0;
}


//Created by Dimon
#include <iostream>
#include <algorithm>
#include <cmath>

#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>

using namespace std;

void main()
{
	int n, p;
	char ch;
	cin >> n >> p;

	if ((p < 3) && (n > 1))
	{
		cout << "NO";
		exit(0);
	}

	vector<int> s(n+1);
	for (int i = 1; i <= n; i++)
	{
		cin >> ch;
		s[i] = ch-'a';
	}

	s[0] = -1;
	int pos = -1;
	bool l = false;
	for (int i = n; i > 1; i--)
	{
		for (int j = s[i]+1; j < p; j++)
		{
			if ((j != s[i-1]) && (j != s[i-2]))
			{
				s[i] = j;
				pos = i;
				l = true;
				break;
			}
		}
		if (l) break;
	}

	if (pos == -1)
		if (s[1] < p-1)
		{
			pos = 1;
			s[1]++;
		}
		else
		{
			cout << "NO";
			exit(0);
		}

	for (int i = pos+1; i <= n; i++)
	{
		for (int j = 0; j < p; j++)
		{
			if ((j != s[i-1])&&(j != s[i-2]))
			{
				s[i] = j;
				break;
			}
		}
	}

	for (int i = 1; i <= n; i++)
		cout << char('a' + s[i]);
}


//Created by Dimon
#include <iostream>
#include <algorithm>
#include <cmath>

#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>

using namespace std;

void main()
{
	int n, p;
	char ch;
	cin >> n >> p;

	vector<int> s(n+1);
	for (int i = 1; i <= n; i++)
	{
		cin >> ch;
		s[i] = ch-'a';
	}

	s[0] = -1;
	int tmp;
	while(true)
	{
		s[n]++;
		tmp = n;
		while(s[tmp]==p)
		{
			s[tmp]=0;
			s[tmp-1]++;
			tmp--;
		}
		if (s[0] == 0)
		{
			cout <<"NO";
			exit(0);
		}
		bool pal = false;
		for (int i = 1; i <= n-1; i++)
		{
			if ((s[i] == s[i+1]) || (s[i-1] == s[i+1])) { pal = true; break; }
		}
		if (!pal) break;
	}

	for (int i = 1; i <= n; i++)
		cout << char('a' + s[i]);
}


//Created by Dimon
#include <iostream>
#include <algorithm>
#include <cmath>

#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>

using namespace std;

void main()
{
	int n, p;
	char ch;
	cin >> n >> p;

	if ((p < 3) && (n > 2))
	{
		cout << "NO";
		exit(0);
	}

	vector<int> s(n+1);
	for (int i = 1; i <= n; i++)
	{
		cin >> ch;
		s[i] = ch-'a';
	}

	s[0] = -1;
	int pos = -1;
	bool l = false;
	for (int i = n; i > 1; i--)
	{
		for (int j = s[i]+1; j < p; j++)
		{
			if ((j != s[i-1]) && (j != s[i-2]))
			{
				s[i] = j;
				pos = i;
				l = true;
				break;
			}
		}
		if (l) break;
	}

	if (pos == -1)
		if (s[1] < p-1)
		{
			pos = 1;
			s[1]++;
		}
		else
		{
			cout << "NO";
			exit(0);
		}

	for (int i = pos+1; i <= n; i++)
	{
		for (int j = 0; j < p; j++)
		{
			if ((j != s[i-1])&&(j != s[i-2]))
			{
				s[i] = j;
				break;
			}
		}
	}

	for (int i = 1; i <= n; i++)
		cout << char('a' + s[i]);
}


#include <iostream>

using namespace std;

int i,j,k,n,p,q;
char s[1001];
bool g;

bool palindrom(char *s,int x,int y)
{
	int z = (y-x+1)/2;
	for(int i=0;i<z;++i)
		if(s[x+i]!=s[y-i])
			return false;
	return true;
}

int next_string(char *s,int n,int p,int q)
{
	if(q==-1)
		q = n-1;
	for(int i=q;i>=0;--i)
	{
		++s[i];
		if(s[i]<'a'+p)
		{
			for(int j=i+1;j<n;++j)
				s[j] = 'a';
			return i;
		}
		else
			s[i] = 'a';
	}
	return -1;
}

int main()
{
	cin>>n>>p>>s; q = -1;
	while(true)
	{
		k = next_string(s,n,p,q);
		if(k==-1)
		{
			cout<<"NO";
			break;
		}
		else
		{
			g = true; q = -1;
			for(j=k;j<n && g;++j)
				for(i=0;i<j && g;++i)
					if(palindrom(s,i,j))
					{
						g = false;
						q = j;
					}
			if(g)
			{
				cout<<s;
				break;
			}
		}
	}
	return 0;
}


#include <iostream>

using namespace std;

int i,j,k,n,p;
char s[1001];
bool g;

bool palindrom(char *s,int x,int y)
{
	int z = (y-x+1)/2;
	for(int i=0;i<z;++i)
		if(s[x+i]!=s[y-i])
			return false;
	return true;
}

int next_string(char *s,int n,int p)
{
	for(int i=n-1;i>=0;--i)
	{
		++s[i];
		if(s[i]<'a'+p)
			return i;
		else
			s[i] = 'a';
	}
	return -1;
}

int main()
{
	cin>>n>>p>>s;
	while(true)
	{
		k = next_string(s,n,p);
		if(k==-1)
		{
			cout<<"NO";
			break;
		}
		else
		{
			g = true;
			for(j=k;j<n && g;++j)
				for(i=0;i<j && g;++i)
					if(palindrom(s,i,j))
						g = false;
			if(g)
			{
				cout<<s;
				break;
			}
		}
	}
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define li long long
#define mp make_pair
#define pb push_back
char a[1200];
char gr;
bool fl[1200];
int n,p,n1;
bool flagoflag=false;
void rec(int u)
{
	if((a[u]+1<gr) && (a[u]+1!=a[u-1]) && (a[u]+1!=a[u-2]))
	{
		a[u]=a[u]+1;
		return;
	}
	if((a[u]+2<gr) && (a[u]+2!=a[u-1]) && (a[u]+2!=a[u-2]))
	{
		a[u]=a[u]+2;
		return;
	}
	if((a[u]+3<gr) && (a[u]+3!=a[u-1]) && (a[u]+3!=a[u-2]))
	{
		a[u]=a[u]+3;
		return;
	}
	if(u==2)
		flagoflag=true;
	rec(u-1);
	if(flagoflag)
		return;
	for(int i=0;i<p;i++)
		if(('a'+i!=a[u-1]) && ('a'+i!=a[u-2]))
		{
			a[u]='a'+i;
			break;
		}
}

int main()
{
	scanf("%d %d\n",&n,&p);
	n1=n+1;
	gr='a'+p;
	for(int i=2;i<=n1;i++)
		scanf("%c",&a[i]);
	rec(n1);
	if(flagoflag)
		cout<<"NO";
	else
		for(int i=2;i<=n1;i++)
			cout<<a[i];
	return 0;
}


#pragma comment(linker,"/STACK:102400000,102400000")
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<cstdio>
#include<queue>
#include<map>
#include<set>
#include<time.h>
#include<cstdlib>
#include<list>
#include<cstring>
#include<iterator>
using namespace std;
#define inf 100000000
#define PI acos(-1.0)
#define FIR 1,n,1
#define LEFT l,mid,dq<<1
#define RIGHT mid+1,r,dq<<1|1
#define MID (l+r)>>1
#define LL __int64
template<class _T> inline _T minn(_T i,_T j){return i>j?j:i;}
template<class _T> inline _T maxx(_T i,_T j){return i>j?i:j;}
template<class _T> inline void swapp(_T &i,_T &j){_T o=i;i=j;j=o;}
int a[1005],p;
char c[1005];
int A(int v,int x,int y){
	int i;
	for(i=v+1;i<p;i++)
		if(i!=x&&i!=y)
			return i;
	return -1;
}
int B(int x,int y){
	int i;
	for(i=0;i<p;i++)
		if(i!=x&&i!=y)
			return i;
	return -1;
}
int main(){
	int n,b,i;
	scanf("%d%d",&n,&p);
	scanf("%s",c);
	for(i=0;i<n;i++)
		a[i]=c[i]-'a';
	for(i=n-1;i>=0;i--){
		if(i==0){
			b=A(a[i],-1,-1);
			if(b!=-1)break;
		}else if(i==1){
			b=A(a[i],a[i-1],-1);
			if(b!=-1)break;
		}else{
			b=A(a[i],a[i-1],a[i-2]);
			if(b!=-1)break;
		}
	}
	if(i>=0){
		a[i]=b;
		for(i=i+1;i<n;i++){
			if(i==1)
				a[i]=B(a[i-1],-1);
			else
				a[i]=B(a[i-1],a[i-2]);
		}
		for(i=0;i<n;i++)
			printf("%c",a[i]+'a');
		printf("\n");
	}else{
		printf("NO\n");
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdio>
#include<stdlib.h>
#include<sstream>
#include<list>
#include<math.h>
#include<map>
#include<set>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<fstream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<cstring>
#include <deque>
#include<stack>
using namespace std;

#define ALL(a) a.begin(),a.end()
#define CLR(a) memset(a,0,sizeof(a))
#define PB push_back
#define PI acos(-1.0)
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
long long GCDFast(long long a, long long b){ while (b)b ^= a ^= b ^= a %= b;  return a; }
#define SET(a) memset(a,-1,sizeof(a))
#define ALL_BITS ((1 << 31) - 1)
#define NEG_BITS(mask) (mask ^= ALL_BITS)
#define TEST_BIT(mask, i) (mask & (1 << i))
#define ON_BIT(mask, i) (mask |= (1 << i))
#define OFF_BIT(mask, i) (mask &= NEG_BITS(1 << i))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define MX 100010
#define pii pair<int,int>
#define LL long long
// UP, RIGHT, DOWN, LEFT, UPPER-RIGHT, LOWER-RIGHT, LOWER-LEFT, UPPER-LEFT
int dx[8] = { -1, 0, 1, 0, -1, 1, 1, -1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

#define mx 300005
int arr[mx], arrY[mx], arrX[mx];

struct T{
	LL sum, propValue;
}tree[mx * 3];
//node present node,l-r present range
void init(int node, int l, int r)//it will transform the array into tree
{
	if (l == r){
		tree[node].sum = arr[l];
		return;
	}
	int Left = node * 2;
	int Right = node * 2 + 1;
	int mid = (l + r) / 2;
	init(Left, l, mid);
	init(Right, mid + 1, r);

	if (tree[Left].sum >= 0)
		tree[node].sum += tree[Left].sum;

	if (tree[Right].sum >= 0)
		tree[node].sum += tree[Right].sum;

	//tree[node] = std::min(tree[Left], tree[Right]);
}
//l=starting point of range
//r=ending point of range
LL query(int node, int l, int r, int qL, int qR, LL carry)// check if the function is relevant or not
{
	cout << "node number " << node << " left " << l << " right " << r << " carry " << carry << "\n";
	if (qL > r || qR < l) {
		return -1; //out of range
	}
	if (l >= qL && r <= qR){
		cout << "assinged value " << tree[node].propValue << "\n";
		//return tree[node].sum + carry*(r - l + 1); //releveant segment
		return std::max(tree[node].propValue, carry);
	}
	int Left = node * 2; //divide again
	int Right = node * 2 + 1;
	int mid = (l + r) / 2;
	LL p1 = query(Left, l, mid, qL, qR, std::max(tree[node].propValue, carry));
	LL p2 = query(Right, mid + 1, r, qL, qR, std::max(tree[node].propValue, carry));

	//return p1 + p2; //summation of left and right segment;
	//cout <<" "<<p1 <<" "<< p2 << "\n";

	if (p1 != -1)
		return p1;
	else if (p2 != -1)
		return p2;
}
void update(int node, int l, int r, int uL, int uR, LL newvalue)
{

	if (uL > r || uR < l)
		return;
	if (l >= uL && r <= uR) {

		//tree[node].sum += ((r - l + 1)*newvalue);
		tree[node].propValue = newvalue;
		return;
	}
	int Left = node * 2;
	int Right = node * 2 + 1;
	int mid = (l + r) / 2;
	update(Left, l, mid, uL, uR, newvalue);
	update(Right, mid + 1, r, uL, uR, newvalue);
	//tree[node].sum = tree[Left].sum + tree[Right].sum + ((r - l + 1)*tree[node].propValue);
}
LL N, P;
string STR;

bool isValidChar(int pos, char ch){
	if (pos == 0) return true;
	if (pos == 1){
		if (STR[0] != ch)
			return true;
		return false;
	}
	if (STR[pos - 1] != ch && STR[pos - 2] != ch)
		return true;

	return false;
}
char nextChar(int pos){

	for (char ch = STR[pos] + 1; ch < ('a' + P); ch++){
		if (isValidChar(pos, ch))
			return ch;
	}
	return STR[pos];
}
void buildNext(int startPos){
	for (int i = startPos; i < N; i++){
		if (STR[i - 1] != 'a' && (i == 1 || STR[i - 2] != 'a'))
			STR[i] = 'a';
		else if (STR[i - 1] != 'b' && (i == 1 || STR[i - 2] != 'b'))
			STR[i] = 'b';
		else
			STR[i] = 'c';
	}
}
int main() {
	//freopen ("d:/Codejam/B-small-attempt0.in","r",stdin);
	//freopen ("d:/Codejam/output1.txt","w",stdout);
	LL n, i, j, k, temp, m;
	LL x, y, z, sum, test_case = 0, length, ans, test = 0, l, w, num, t, index;
	string str, str1;

	ios::sync_with_stdio(false);
	LL a, b, q ;

	while (cin >> N >>P){

		cin >> STR;

		if (P == 1){
			cout << "NO\n";
			continue;
		}
		if (P == 2){
			if (STR[0] == 'b'){
				cout << "NO\n";
				continue;
			}
			else if (N == 2){
				cout << "ba\n";
				continue;
			}
			else{ // N == 1
				cout << "b\n";
				continue;
			}
		}
		bool flag = false;
		for (i = N - 1; i >= 0; i--){
			char ch = nextChar(i);
			if (ch != STR[i]){
				STR[i] = ch;
				buildNext(i + 1);
				cout << STR << "\n";
				flag = true;
				break;
			}
		}
		if (!flag)
			cout << "NO\n";

	}

	return 0;
}


#include <cstdlib>

#include <iostream>

#include <algorithm>
using namespace std;

#define endl '\n'
//===========================//

int n, p;
char a[1010];

//===========================//
bool isCool()
{
    for (int i = 0; i < n - 1; ++i)
        if (a[i] == a[i + 1] || a[i] == a[i + 2])
            return false;
    return true;
}

bool makeNext()
{
    for (int i = n - 1; i >= 0; --i)
        if (a[i] < 'a' + p - 1)
        {
            a[i]++;
            for (int j = i + 1; j < n; ++j)
                a[j] = 'a';
            return true;
        }
    return false;
}
//===========================//

void solve()
{
    cin >> n >> p;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    while (1)
    {
            bool flag = makeNext();
        if (!flag)
        {
            cout << "NO";
            return;
        }
        if (isCool())
            break;
    }
    for (int i = 0; i < n; ++i)
        cout << a[i];
}

//===========================//

int main()
{
    #ifdef TORTE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include <cstdlib>

#include <iostream>

#include <algorithm>
using namespace std;

#define endl '\n'
//===========================//

int n, p;
char a[1010];

//===========================//

bool MakeNew(int start)
{
    a[start]++;
    for (int i = start + 1; i < n; ++i)
    {
        a[i] = 'a';
        while (i > 0 && a[i] == a[i - 1] || i > 1 && a[i] == a[i - 2])
            a[i]++;
    }
    for (int i = 0; i < n - 1; ++i)
        if (a[i] == a[i + 1] || a[i] == a[i + 2])
            return false;
    return true;
}

//===========================//

void solve()
{
    cin >> n >> p >> a;

        bool flag = false;
        for (int j = n - 1; j >= 0 && !flag; --j)
            while (a[j] < 'a' + p - 1 && !flag)
                flag = MakeNew(j);
        if (flag)
            for (int i = 0; i < n; ++i)
                cout << a[i];
        else cout << "NO";

}

//===========================//

int main()
{
    #ifdef TORTE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
	string s;
	int n;
	cin >> n;
	int p;
	cin >> p;
	int last = int('a');
	cin >> s;
	int fl = 0;
	int num = 0;
	int fl2 =0;
	for ( int i = n-1; i >= 0; i--)
		if(fl2 == 0)
		for ( int j = int ( s[i] )+1; j <= last + p-1; j++)
		{
			if ( ( i == 0 || j != int( s[i-1])) &&(i-2<0 || j != int( s[i-2] ) ) )
			{
				fl = 1;
				s[i] = char(j);
				num = i;
				fl2 = 1;
				break;

			}
		}
		if ( fl == 0 )
		{
			cout << "NO";
			return 0;
		}
		for ( int i = num+1; i < n; i++ )
			for ( int j = int ( s[i] )-1; j >= last ; j--)
			{
				if ( ( i == 0 || j != int( s[i-1])) &&(i-2<0 || j != int( s[i-2] ) ) )
				{
					s[i] = char(j);

				}
			}
			cout << s;
}


#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
	string s;
	int n;
	cin >> n;
	int p;
	cin >> p;
	int last = int('a');
	cin >> s;
	int fl = 0;
	int num = 0;
	for ( int i = n-1; i >= 0; i--)
		for ( int j = int ( s[i] )+1; j <= last + p-1; j++)
		{
			if ( ( i == 0 || j != int( s[i-1])) &&(i-2<0 || j != int( s[i-2] ) ) )
			{
				fl = 1;
				s[i] = char(j);
				num = i;
				break;

			}
		}
		if ( fl == 0 )
		{
			cout << "NO";
			return 0;
		}
		for ( int i = num+1; i < n; i++ )
			for ( int j = int ( s[i] )-1; j >= last ; j--)
			{
				if ( j != int( s[i-1]) && j != int( s[i-2] ) )
				{
					s[i] = char(j);

				}
			}
			cout << s;
}


#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
	string s;
	int n;
	cin >> n;
	int p;
	cin >> p;
	int last = int('a');
	cin >> s;
	int fl = 0;
	int num = 0;
	int fl2 =0;
	for ( int i = n-1; i >= 0; i--)
		if(fl2 == 0)
		for ( int j = int ( s[i] )+1; j <= last + p-1; j++)
		{
			if ( ( i == 0 || j != int( s[i-1])) &&(i-1 <=0 || j != int( s[i-2] ) ) )
			{
				fl = 1;
				s[i] = char(j);
				num = i;
				fl2 = 1;
				break;

			}
		}
		if ( fl == 0 )
		{
			cout << "NO";
			return 0;
		}
		for ( int i = num+1; i < n; i++ )
			for ( int j = last; j <= last+p-1 ; j++)
			{
				if ( ( i == 0 || j != int( s[i-1])) &&(i-2<0 || j != int( s[i-2] ) ) )
				{
					s[i] = char(j);
					break;

				}
			}
			cout << s;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <functional>
using namespace std;
#define LL __int64
#define ll long long
#define INF 999999999
#define MOD 1000000007

#define in freopen("c:\\users\\mfmy\\desktop\\input.txt", "r", stdin)
#define out freopen("c:\\users\\mfmy\\desktop\\output.txt", "w", stdout)

const int maxn = 100000 + 5;

int n, p;
char ch[1005];

int main()
{
    while(~scanf("%d%d", &n, &p))
    {
        scanf("%s", ch);
        int temp = 0;
        while(1)
        {
            ch[n - 1]++;
            int pos = n - 1;
            while(ch[pos] > 'a' + p - 1)
            {
                ch[pos] = 'a';
                pos--;
                if(pos < 0)
                {
                    temp = 1;
                    break;
                }
                ch[pos]++;
            }
            while((pos >= 1 && (ch[pos] == ch[pos - 1])) || (pos > 1 && (ch[pos] == ch[pos - 1] || ch[pos] == ch[pos - 2])))
            {
                ch[pos]++;
                while(ch[pos] > 'a' + p - 1)
                {
                    ch[pos] = 'a';
                    pos--;
                    if(pos < 0)
                    {
                        temp = 1;
                        break;
                    }
                    ch[pos]++;
                }
                if(temp == 1)
                    break;
            }
            if(temp == 1)
                break;
            if(ch[n - 1] == ch[n - 2] || ch[n - 1] == ch[n - 3])
                continue;
            break;
        }
        if(temp == 1)
            printf("NO\n");
        else
        {
            printf("%s", ch);
            printf("\n");
        }
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <functional>
using namespace std;
#define LL __int64
#define ll long long
#define INF 999999999
#define MOD 1000000007

#define in freopen("c:\\users\\mfmy\\desktop\\input.txt", "r", stdin)
#define out freopen("c:\\users\\mfmy\\desktop\\output.txt", "w", stdout)

const int maxn = 100000 + 5;

int n, p;
char ch[maxn];

int main()
{
	while(~scanf("%d%d", &n, &p))
	{
		getchar();
		scanf("%s", ch);
		int len = strlen(ch);
		int flag = 0;
		int pos = len - 1, ans;
		for(int i = len - 1; i >= 0; i--)
		{
			int x = ch[i] - 'a' + 1;
			if(i >= 2)
			{
				int l = ch[i - 2] - 'a' + 1;
				int r = ch[i - 1] - 'a' + 1;
				for(int k = x + 1; k <= p; k++)
				{
					if(k != l && k != r)
					{
						flag = 1;
						ans = k - 1;
						break;
					}
				}
				if(flag)
					break;
				pos = i - 1;
			}
			else if(i == 1)
			{
				int l = ch[i - 1] - 'a' + 1;
				for(int k = x + 1; k <= p; k++)
				{
					if(k != l)
					{
						flag = l;
						ans = k - 1;
						break;
					}
				}
				if(flag)
					break;
				pos = i - 1;
			}
			else
			{
				if(x != p)
				{
					flag = 1;
					ans = x;
					break;
				}
				pos = i -1;
			}
		}
		if(pos == -1)
		{
			printf("NO\n");
			continue;
		}
		ch[pos] = ans + 'a';
		pos++;
		for(int i = pos; i < len; i++)
		{
			if(i == 1)
			{
				int l = ch[i - 1] - 'a';
				for(int k = 0; k < p; k++)
				{
					if(k != l)
					{
						ch[i] = k + 'a';
						break;
					}
				}
			}
			else
			{
				int l = ch[i - 2] - 'a';
				int r = ch[i - 1] - 'a';
				for(int k = 0; k < p; k++)
				{
					if(k != l && k != r)
					{
						ch[i] = k + 'a';
						break;
					}
				}
			}
		}
		printf("%s\n", ch);
	}
	return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <cstddef>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <sstream>
#include <cmath>

#define ll long long
#define ld long double
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forft(i, from, to) for (int i = int(from); i < int(to); i++)
#define mp make_pair
#define pb push_back
#define pt pair<int, int>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define scan_arr(a, n) for (int i = 0; i < int(n); i++) scanf("%d", &a[i])
#define print_arr(a, n) for (int i = 0; i < int(n); i++) printf("%d ", a[i])
#define X first
#define Y second
#define correct(x, y, n, m) ((x >= 0) && (y >= 0) && (x < n) && (y < m))
#define has_byte(x, i) (x & (1 << i))
#define set_byte(x, i) x |= (1 << i)

using namespace std;

typedef pair<ld, ld> pd;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const int INF = (int)1e9;
const ll INF_LL = (ll)1e18;
const int N = 5e3;
const int M = 11;
const ll MOD = 1e9 + 7;

int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};

int main()
{
    //freopen("input.txt", "rt", stdin);
   // freopen("output.txt", "wt", stdout);

	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;

	vector<int> a(n);

	forn(i, n)
	{
		a[i] = int(s[i] - 'a');
	}

	int ind = n - 1;

	while (ind >= 0)
	{
		a[ind]++;

		while (a[ind] < p)
		{
			if ((ind > 0 && a[ind] == a[ind - 1]) || (ind > 1 && a[ind] == a[ind - 2]))
			{
				a[ind]++;
			}
			else
			{
				break;
			}
		}

		if (a[ind] < p)
		{
			break;
		}

		a[ind] = 0;
		ind--;
	}

	if (ind < 0)
	{
		cout << "NO" << endl;
		return 0;
	}

	forft(i, ind + 1, n)
	{
		a[i] = 0;

		while (a[i] < p)
		{
			if ((i > 0 && a[i] == a[i - 1]) || (i > 1 && a[i] == a[i - 2]))
			{
				a[i]++;
			}
			else
			{
				break;
			}
		}

		if (a[i] == p)
		{
			cout << "NO" << endl;
			return 0;
		}
	}

	forn(i, n)
	{
		cout << char(a[i] + 'a');
	}

	return 0;
}


#include<cassert>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<set>
#include<math.h>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = 1; i <= (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int N = 100009;
const int INF = 1e9;
const int MOD = INF + 7;
const li INF64 = 1ll * INF * INF;
const ld eps = 1e-9;

int n, k;
string s;

bool check(int pos, char x){
    if(pos-1 >= 0 && s[pos-1] == x)
        return false;
    if(pos-2 >= 0 && s[pos-2] == x)
        return false;

    return true;
}

void zbs(){
    if(k == 1){
        cout << "NO";
        return;
    }

    if(s == "aa"){
        cout << "ab";
        return;
    }
    if(s == "ab"){
        cout << "ba";
        return;
    }
    if(s == "ba"){
        cout << "NO";
        return;
    }
    if(s == "bb"){
        cout << "NO";
        return;
    }
    if(s == "a"){
        cout << "b";
        return;
    }
    if(s == "b"){
        cout << "NO";
        return;
    }
}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k >> s;
    if(k <= 2){
        zbs();
        return 0;
    }
    int pos = -1;
    char xx;
    forn(i, n){
        ford(j, 3)
            if(s[i]-'a'+j < k)
                if(check(i, s[i]+j))
                    pos = i, xx = s[i]+j;
    }

    if(pos == -1){
        cout << "NO";
        return 0;
    }

    s[pos] = xx;
    for(int i = pos+1; i < n; ++i){
        for(char x = 'a'; x <= 'c'; ++x){
            if(i-1 >= 0 && x == s[i-1])
                continue;
            if(i-2 >= 0 && x == s[i-2])
                continue;
            s[i] = x;
            break;
        }
    }

    cout  << s;
}


#include<cassert>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<set>
#include<math.h>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = 1; i <= (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int N = 100009;
const int INF = 1e9;
const int MOD = INF + 7;
const li INF64 = 1ll * INF * INF;
const ld eps = 1e-9;

int n, k;
string s;

bool check(int pos, char x){
    if(pos-1 >= 0 && s[pos-1] == x)
        return false;
    if(pos-2 >= 0 && s[pos-2] == x)
        return false;

    return true;
}

void zbs(){
    if(k == 1){
        cout << "NO";
        return;
    }

    if(s == "aa"){
        cout << "ab";
        return;
    }
    if(s == "ab"){
        cout << "ba";
        return;
    }
    if(s == "ba"){
        cout << "NO";
        return;
    }
    if(s == "bb"){
        cout << "NO";
        return;
    }
}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k >> s;
    if(k <= 2){
        zbs();
        return 0;
    }
    int pos = -1;
    char xx;
    forn(i, n){
        ford(j, 3)
            if(s[i]-'a'+j < k)
                if(check(i, s[i]+j))
                    pos = i, xx = s[i]+j;
    }

    if(pos == -1){
        cout << "NO";
        return 0;
    }

    s[pos] = xx;
    for(int i = pos+1; i < n; ++i){
        for(char x = 'a'; x <= 'c'; ++x){
            if(i-1 >= 0 && x == s[i-1])
                continue;
            if(i-2 >= 0 && x == s[i-2])
                continue;
            s[i] = x;
            break;
        }
    }

    cout  << s;
}


#include<cassert>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<set>
#include<math.h>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = 1; i <= (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int N = 100009;
const int INF = 1e9;
const int MOD = INF + 7;
const li INF64 = 1ll * INF * INF;
const ld eps = 1e-9;

int n, k;
string s;

bool check(int pos, char x){
    if(pos-1 >= 0 && s[pos-1] == x)
        return false;
    if(pos-2 >= 0 && s[pos-2] == x)
        return false;

    return true;
}

void zbs(){
    if(k == 1){
        cout << "NO";
        return;
    }

    if(s == "aa"){
        cout << "YES\nab";
        return;
    }
    if(s == "ab"){
        cout << "YES\nba";
        return;
    }
    if(s == "ba"){
        cout << "NO";
        return;
    }
    if(s == "bb"){
        cout << "NO";
        return;
    }
}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k >> s;
    if(k <= 2){
        zbs();
        return 0;
    }
    int pos = -1;
    char xx;
    forn(i, n){
        ford(j, 3)
            if(s[i]-'a'+j < k)
                if(check(pos, s[i]+j))
                    pos = i, xx = s[i]+j;
    }

    if(pos == -1){
        cout << "NO";
        return 0;
    }

    s[pos] = xx;
    for(int i = pos+1; i < n; ++i){
        for(char x = 'a'; x <= 'c'; ++x){
            if(i-1 >= 0 && x == s[i-1])
                continue;
            if(i-2 >= 0 && x == s[i-2])
                continue;
            s[i] = x;
            break;
        }
    }

    cout  << s;
}


#include<cassert>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<set>
#include<math.h>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = 1; i <= (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int N = 100009;
const int INF = 1e9;
const int MOD = INF + 7;
const li INF64 = 1ll * INF * INF;
const ld eps = 1e-9;

int n, k;
string s;

bool check(int pos, char x){
    if(pos-1 >= 0 && s[pos-1] == x)
        return false;
    if(pos-2 >= 0 && s[pos-2] == x)
        return false;

    return true;
}

void zbs(){
    if(k == 1){
        cout << "NO";
        return;
    }

    if(s == "aa"){
        cout << "YES\nab";
        return;
    }
    if(s == "ab"){
        cout << "YES\nba";
        return;
    }
    if(s == "ba"){
        cout << "NO";
        return;
    }
    if(s == "bb"){
        cout << "NO";
        return;
    }
}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k >> s;
    if(k <= 2){
        zbs();
        return 0;
    }
    int pos = -1;
    char xx;
    forn(i, n){
        ford(j, 3)
            if(s[i]-'a'+j < k)
                if(check(i, s[i]+j))
                    pos = i, xx = s[i]+j;
    }

    if(pos == -1){
        cout << "NO";
        return 0;
    }

    s[pos] = xx;
    for(int i = pos+1; i < n; ++i){
        for(char x = 'a'; x <= 'c'; ++x){
            if(i-1 >= 0 && x == s[i-1])
                continue;
            if(i-2 >= 0 && x == s[i-2])
                continue;
            s[i] = x;
            break;
        }
    }

    cout  << s;
}


#include<cassert>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<set>
#include<math.h>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = 1; i <= (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int N = 100009;
const int INF = 1e9;
const int MOD = INF + 7;
const li INF64 = 1ll * INF * INF;
const ld eps = 1e-9;

int n, k;
string s;

bool check(int pos, char x){
    if(pos+1 < n && s[pos+1] == x)
        return false;
    if(pos+2 < n && s[pos+2] == x)
        return false;
    if(pos-1 >= 0 && s[pos-1] == x)
        return false;
    if(pos-2 >= 0 && s[pos-2] == x)
        return false;

    return true;
}

void zbs(){
    if(k == 1){
        cout << "NO";
        return;
    }

    if(s == "aa"){
        cout << "YES\nab";
        return;
    }
    if(s == "ab"){
        cout << "YES\nba";
        return;
    }
    if(s == "ba"){
        cout << "NO";
        return;
    }
    if(s == "bb"){
        cout << "NO";
        return;
    }
}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k >> s;
    if(k <= 2){
        zbs();
        return 0;
    }
    int pos = -1;
    char xx;
    forn(i, n){
        ford(j, 3)
            if(s[i]-'a'+j < k)
                if(check(pos, s[i]+j))
                    pos = i, xx = s[i]+j;
    }

    if(pos == -1){
        cout << "NO";
        return 0;
    }

    s[pos] = xx;
    for(int i = pos+1; i < n; ++i){
        for(char x = 'a'; x <= 'c'; ++x){
            if(i-1 >= 0 && x == s[i-1])
                continue;
            if(i-2 >= 0 && x == s[i-2])
                continue;
            s[i] = x;
            break;
        }
    }

    cout << "YES\n" << s;
}


#include<cassert>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<set>
#include<math.h>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = 1; i <= (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int N = 100009;
const int INF = 1e9;
const int MOD = INF + 7;
const li INF64 = 1ll * INF * INF;
const ld eps = 1e-9;

int n, k;
string s;

bool check(int pos, char x){
    if(pos-1 >= 0 && s[pos-1] == x)
        return false;
    if(pos-2 >= 0 && s[pos-2] == x)
        return false;

    return true;
}

void zbs(){
    if(k == 1){
        cout << "NO";
        return;
    }

    if(s == "aa"){
        cout << "ab";
        return;
    }
    if(s == "ab"){
        cout << "ba";
        return;
    }
    if(s == "ba"){
        cout << "NO";
        return;
    }
    if(s == "bb"){
        cout << "NO";
        return;
    }
    if(s == "a"){
        cout << "b";
        return;
    }
    if(s == "b"){
        cout << "NO";
        return;
    }
}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k >> s;
    if(k <= 2){
        zbs();
        return 0;
    }
    int pos = -1;
    char xx;
    forn(i, n){
        ford(j, 3)
            if(s[i]-'a'+j < k)
                if(check(i, s[i]+j)){
                    pos = i, xx = s[i]+j;
                    break;
                }
    }

    if(pos == -1){
        cout << "NO";
        return 0;
    }

    s[pos] = xx;
    for(int i = pos+1; i < n; ++i){
        for(char x = 'a'; x <= 'c'; ++x){
            if(i-1 >= 0 && x == s[i-1])
                continue;
            if(i-2 >= 0 && x == s[i-2])
                continue;
            s[i] = x;
            break;
        }
    }

    cout  << s;
}


#include<cassert>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<set>
#include<math.h>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = 1; i <= (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int N = 100009;
const int INF = 1e9;
const int MOD = INF + 7;
const li INF64 = 1ll * INF * INF;
const ld eps = 1e-9;

int n, k;
string s;

bool check(int pos, char x){
    if(pos+1 < n && s[pos+1] == x)
        return false;
    if(pos+2 < n && s[pos+2] == x)
        return false;
    if(pos-1 >= 0 && s[pos-1] == x)
        return false;
    if(pos-2 >= 0 && s[pos-2] == x)
        return false;

    return true;
}

void zbs(){
    if(k == 1){
        cout << "NO";
        return;
    }

    if(s == "aa"){
        cout << "YES\nab";
        return;
    }
    if(s == "ab"){
        cout << "YES\nba";
        return;
    }
    if(s == "ba"){
        cout << "NO";
        return;
    }
    if(s == "bb"){
        cout << "NO";
        return;
    }
}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k >> s;
    if(k <= 2){
        zbs();
        return 0;
    }
    int pos = -1;
    char xx;
    forn(i, n){
        ford(j, 3)
            if(s[i]-'a'+j < k)
                if(check(pos, s[i]+j))
                    pos = i, xx = s[i]+j;
    }

    if(pos == -1){
        cout << "NO";
        return 0;
    }

    s[pos] = xx;
    for(int i = pos+1; i < n; ++i){
        for(char x = 'a'; x <= 'c'; ++x){
            if(i-1 >= 0 && x == s[i-1])
                continue;
            if(i-2 >= 0 && x == s[i-2])
                continue;
            s[i] = x;
            break;
        }
    }

    cout  << s;
}


#include<iostream>
#include<string>
#include<cmath>
#include<stdio.h>
#include<algorithm>
using namespace std;
long long l, r, n, a, b, x, k, h[1000];
char alph[26], str[1000], c;
string s, ss;
int nextel1( int pos) {
	int num = -1, i;
	if( pos == 0 && s[0] != alph[n - 1]) return( int(s[0]) - 96 );
	if( pos == 1 ) {
			for( i = int(s[pos]) - 97 + 1; i < n; i++ ){
				if( alph[i] != s[pos - 1] ){
					num = i;
					break;
				}
			}
	}
	else {
		for( i = int(s[pos]) - 97 + 1; i < n; i++ ){
			if( alph[i] != s[pos - 2] && alph[i] != s[pos - 1] ){
				num = i;
				break;
			}
		}
	}
	return( num );
}
int nextel2( int pos) {
	int num = -1, i;
	if( pos == 0 && s[0] != alph[n - 1]) return( int(s[0]) - 96 );
	if( pos == 1 ) {
		for( i = 0; i < n; i++ ){
			if( alph[i] != str[pos - 1] ){
				num = i;
				break;
			}
		}
	}
	else {
		for( i = 0; i < n; i++ ){
			if( alph[i] != str[pos - 2] && alph[i] != str[pos - 1] ){
				num = i;
				break;
			}
		}
	}
	return( num );
}
int main() {
	int  i, j;
	cin >> k >> n;
	cin >> s;
	for( i = 0; i < 26; i++ ) alph[i] = char(i + 97);
	for( i = k - 1; i >= 0; i-- ) {
		if( nextel1( i ) != -1 ) {
			l = i;
			c = alph[nextel1( i )];
			break;
		}
		else if( i == 0 ) {
			cout << "NO";
			return 0;
		}
	}
	for( i = 0; i < k; i++ ) {
		if( i < l ) str[i] = s[i];
		if( i == l ) str[i] = c;
		if( i > l ) str[i] = alph[nextel2( i )];
	}
	for( i = 0; i < k; i++ ) cout << str[i];
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <set>
#include <deque>
#include <fstream>

using namespace std;

#define forn(i,n) for (int i = int(0); i < int(n); i++)
#define forb(i,n) for (int i = int(n-1); i >= int(0); i--)
#define for1(i,n) for (int i = int(1); i <= int(n); i++)
#define fore(i,a,n) for (int i = int(a); i < int(n); i++)

#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sz size()
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define min2(a, b) a < b ? a : b
#define max2(a, b) a > b ? a : b
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define dist(x1, y1, x2, y2) sqrt(double (sqr(x1 - x2) + sqr(y1 - y2)))

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int maxn = 105;
const int MAXN = 2000000;
const int logn = 12;
const int inf = int (2e9);
const int alpha = 26;
const int my_hash = 31;
const long long base = ll (1e18);
const long long my_mod = 2674894331;
const long long l_inf = ll (4e18);
const long long mod = ll (1e9+7);
const double pi = acos(-1.0);
const double eps = 1e-6;

int n, p;
string s;

int main() {
    ios_base::sync_with_stdio(0);
	cin >> n >> p >> s;
	while (!s.empty()) {
		if (++s.back() - 'a' == p) {
			s.pop_back();
			continue;
		}
		int m = (int) s.size();
		if (m >= 2 && s[m - 1] == s[m - 2] || m >= 3 && s[m - 1] == s[m - 3])
			continue;
		if (m == n) {
			cout << s;
			exit(0);
		}
		s.push_back('a' - 1);
	}
	printf("NO");
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iomanip>
#include <memory.h>
using namespace std;

const int Nmax=2010;
int n, p;
char a[Nmax];
int q[Nmax];
vector <int> s [30];

bool make (int x, bool t=0){
	int j, k, z;
	for(int i = (t==0 ? 0 : (int)(a[x]-'a')); i<p; i++){
		q[x]=i;
		for(j=0; j<s[i].size(); j++) {
			for(k=s[i][j], z=x; k<=z; k++, z--)
				if(q[k]!=q[z]) break;
			if(k>z) break;
		}

		if(j==s[i].size() && x+1==n) return 1;

		if(j==s[i].size()){
			s[i].push_back(x);
			if(make(x+1, (!(i==(int)a[x]-'a' ? 0 : 1) && t) )) return 1;
			s[i].pop_back();
		}
	}
	return 0;
}

int main (void){
	//freopen("i.txt","r",stdin);
	//freopen("o.txt", "w+", stdout);
	std::ios::sync_with_stdio(false);

	cin >> n >> p >> a;
	int i;
	for(i=n-1; i>=0; i--) if(a[i]+1<'a'+p) { a[i]++; break; } else a[i]='a';
	if(i!=-1) { if(make(0, 1)) for(int i=0; i<n; i++) cout << (char) (q[i]+'a');
				else cout << "NO";}
	else cout << "NO";
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iomanip>
#include <memory.h>
using namespace std;

const int Nmax=2010;
int n, p;
char a[Nmax];
int q[Nmax];
vector <int> s [30];

bool make (int x, bool t=0){
	int j, k, z;
	for(int i = (t==0 ? 0 : (int)(a[x]-'a')); i<p; i++){
		q[x]=i;
		for(j=0; j<s[i].size(); j++) {
			for(k=s[i][j], z=x; k<=z; k++, z--)
				if(q[k]!=q[z]) break;
			if(k>z) break;
		}

		if(j==s[i].size() && x+1==n) return 1;

		if(j==s[i].size()){
			s[i].push_back(x);
			if(make(x+1, (!(i==(int)a[x]-'a' ? 0 : 1) && t) )) return 1;
			s[i].pop_back();
		}
	}
	return 0;
}

int main (void){
	//freopen("i.txt","r",stdin);
	//freopen("o.txt", "w+", stdout);
	std::ios::sync_with_stdio(false);

	cin >> n >> p >> a;
	int i;
	for(i=n-1; i>=0; i--) if(a[i]+1<'a'+p) { a[i]++; break; } else a[i]='a';
	if(i=-1) if(make(0, 1)) for(int i=0; i<n; i++) cout << (char) (q[i]+'a');
			else cout << "NO";
	else cout << "NO";
}


#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <stack>
#include<queue>
#include <cmath>
#include <string>

using namespace std;

bool check(string str)
{
	for(int i = 0; i < str.length() - 1; i++)
	{
		if(i + 1 < str.length() && i + 2 < str.length() && str[i] == str[i+1] || str[i] == str[i+2]) return true;
		else if(i + 1 < str.length() && str[i] == str[i+1]) return true;
	}
	return false;
}

string nextstr(string str, int p)
{
	string s = str;
	bool f = false;
	int index = str.length() - 1;
	for(int i = s.length() - 1; i >= 0; i--)
	{
		if((int)(s[i] - 'a' + 1) < p)
		{
			s[i]++;
			f = true;
			index =  i;
			break;
		}
	}
	if(f)
	{
		for(int i = index + 1; i < str.length(); i++)
		{
			s[i] = 'a';
		}
		return s;
	}
	else return "";
}

int main()
{
	int n, p;
	cin >> n >> p;
	string str;
	cin >> str;
	string res;
	while (true)
	{
		res = nextstr(str, p);
		if(res != "" && !check(res))
		{
			cout << res;
			return 0;
		}
		if(res == "") break;
		else
			str = res;
	}
	cout << "NO";
	return 0;
}


#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    int n, p;
    cin >> n >> p;
    string str;
    cin >> str;
    char l = 'a' + p;
    bool f = false;
    for(int i = str.length() - 1; i >= 0 && !f; i--)
    {
            for(char j = str[i] + 1; j < l; j++)
            {
                if((i == 0 || j != str[i-1]) && (i <= 1 || j != str[i-2]))
                {
                    str[i] = j;
                    for(int k = i + 1; k < n; k++)
                        for(str[j] = 'a'; str[j] < l; str[j]++)
                            if((j == 0 || str[j] != str[j-1]) && (j <= 1 || str[j] != str[j-2]))
                            {
                                break;
                            }
                    f = true;
                    break;
                }
            }
    }
    if(!f)
    {
        cout << "NO";
    }
    else
    {
        cout << str;
    }
    return 0;
}


#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    int n, p;
    cin >> n >> p;
    string str;
    cin >> str;
    char l = 'a' + p;
    bool f = false;
    for(int i = str.length() - 1; i >= 0; i--)
    {
        if(!f)
        {
            for(char j = str[i] + 1; j < l; j++)
            {
                if((i == 0 || j != str[i-1]) && (i <= 1 || j != str[i-2]))
                {
                    str[i] = j;
                    for(int k = i + 1; k < n; k++)
                        for(str[j] = 'a'; str[j] < l; str[j]++)
                            if((j == 0 || str[j] != str[j-1]) && (j <= 1 || str[j] != str[j-2]))
                            {
                                break;
                            }
                    f = true;
                    break;
                }
            }
        }
    }
    if(!f)
    {
        cout << "NO";
    }
    else
    {
        cout << str;
    }
    return 0;
}


#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    int n, p;
    cin >> n >> p;
    string str;
    cin >> str;
    char l = 'a' + p;
    bool f = false;
    for (int i = n - 1; i >= 0; --i)
    {
        if(!f)
        {
            for (char z = str[i] + 1; z < l; ++z)
                if ((i == 0 || z != str[i-1]) && (i <= 1 || z != str[i-2]))
                {
                    str[i] = z;
                    for (int j = i + 1; j < n; ++j)
                        for (str[j] = 'a'; str[j] < l; ++str[j])
                            if ((j == 0 || str[j] != str[j-1]) && (j <= 1 || str[j] != str[j-2]))
                                break;
                    f = true;
                    break;
                }
        }
    }
    if (!f)
    {
        cout << "NO";
    }
    else
    {
        cout << str;
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <map>
#include <assert.h>
#include <set>
#include <bitset>
#define SI(i) scanf("%d", &i)
#define SII(i,j) scanf("%d%d", &i, &j)
#define SIII(i,j, k) scanf("%d%d%d", &i, &j, &k)
#define SL(i) scanf("%I64d", &i)
#define SLL(i,j) scanf("%I64d%I64d", &i, &j)
#define SLLL(i,j, k) scanf("%I64d%I64d%I64d", &i, &j, &k)
#define SS(i) scanf("%s\n", i)
#define SSS(i,j) scanf("%s %s", i, j)
#define SC(i) scanf("%d", &i)
#define SCC(i,j) scanf("%c %c\n", &i, &j)

#define PI(i) printf("%d ", i)
#define PII(i,j) printf("%d %d ", i, j)
#define PL(i) printf("%I64d ", i)
#define PLL(i,j) printf("%I64d %I64d ", i, j)
#define PS(i) printf("%s", i)
#define PSS(i,j) printf("%s %s ", i, j)
#define PC(i) printf("%c", i)
#define PCC(i,j) printf("%c %c ", i, j)
#define PN printf("\n")
#define forin(i, k, n) for(int i = (k); i < (n); ++i)
#define rforin(i, k, n) for(int i = (k); i > (n); --i)
#define mod 1000000007
using namespace std;
int n, p;
char s[10010], s2[10010], ch;
bool is;
int main()
{
#ifdef _DEBUG
	freopen("1.in", "rt", stdin);
	freopen("1.out", "wt", stdout);
#endif

	SII(n, p);
	SS(s+3);
	n += 3;
	forin(i, 3, n)
		s2[i] = s[i];
	rforin(i, n - 1, 2)
	{
		if (s[i] >= 'a' + p)
		{
			is = false;
			continue;
		}
		ch = s[i];
		forin(j, 1, p - ch + 'a')
		{
			if (s[i - 1] == ch + j || s[i - 2] == ch + j)
			{
				is = false;
				continue;
			}
			is = true;
			s[i] = ch + j;
			forin(ii, i + 1, n)
			{
				forin(jj, 0, p)
				{
					if (s[ii - 1] == jj + 'a' || s[ii - 2] == jj + 'a')
					{
						is = false;
						continue;
					}
					is = true;
					s[ii] = jj + 'a';
					break;
				}
			}
			break;
		}
		if (is)
		{
			cout << s+3;
			return 0;
		}
		forin(ii, i, n)
			s[ii] = s2[ii];
	}
	cout << "NO";
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,p,num[1010],tmp[1010];
char s[1010];
int main()
{
	scanf("%d%d",&n,&p);
	scanf("%s",s);
	for(int i=0;i<=n-1;i++)
	{
		num[i]=s[i]-'a';
	}
	bool ok=0;
	int x;
	for(int i=n-1;i>=0;i--)
	{
		x=i;
		for(int j=num[i]+1;j<=p-1;j++)
		{
			if(i>0&&j==num[i-1]) continue;
			if(i>1&&j==num[i-2]) continue;
			tmp[i]=j;
			ok=1;
			bool flag;
			for(int k=i+1;k<=n-1;k++)
			{
				flag=0;
				for(int u=0;u<=p-1;u++)
				{
					if(u==tmp[k-1]) continue;
					if(k==i+1)
					{
						if(i>0&&u==num[i-1]) continue;
					}
					else if(u==tmp[k-2]) continue;
					tmp[k]=u;
					flag=1;
					break;
				}
				if(!flag){ ok=0; break;}
			}
			if(ok) break;
		}
		if(ok) break;
	}
	if(!ok)
	{
		printf("NO\n");
		return 0;
	}
	for(int i=0;i<=x-1;i++)
		printf("%c",num[i]+'a');
	for(int i=x;i<=n-1;i++)
		printf("%c",tmp[i]+'a');
	printf("\n");
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,p,num[1010],tmp[1010];
char s[1010];
int main()
{
	scanf("%d%d",&n,&p);
	scanf("%s",s);
	for(int i=0;i<=n-1;i++)
	{
		num[i]=s[i]-'a';
	}
	bool ok=0;
	int x;
	for(int i=n-1;i>=0;i--)
	{
		for(int j=num[i]+1;j<=p-1;j++)
		{
			if(i>0&&j==num[i-1]) continue;
			if(i>1&&j==num[i-2]) continue;
			tmp[i]=j;
			x=i;
			ok=1;
			for(int k=i+1;k<=n-1;k++)
			{
				bool flag=0;
				for(int u=0;u<=p-1;u++)
				{
					if(u==tmp[k-1]) continue;
					if(k==i+1)
					{
						if(i>0&&u==num[i-1]) continue;
					}
					else if(u==tmp[k-2]) continue;
					tmp[k]=u;
					flag=1;
					break;
				}
				if(!flag){ ok=0; break;}
			}
		}
		if(ok) break;
	}
	if(!ok)
	{
		printf("NO\n");
		return 0;
	}
	for(int i=0;i<=x-1;i++)
		printf("%c",num[i]+'a');
	for(int i=x;i<=n-1;i++)
		printf("%c",tmp[i]+'a');
	printf("\n");
	return 0;
}


#include <iostream>
using namespace std;
int a[1010];
int n,p;
int solve(int pos){
    if(pos==n+1)
        return 1;
    for(int i=a[pos]+1;i<p;i++){
        if((i==a[pos-1]&&pos>1)||((i==a[pos-2]||i==a[pos-1])&&pos>2))
            continue;
        a[pos]=i;
        a[pos+1]=-1;
        return solve(pos+1);
    }
    return 0;
}
int main(){
    cin>>n>>p;
    char c;
    for(int i=1;i<=n;i++){
        cin>>c;
        a[i]=c-'a';
    }
    int ok;
    for(int i=n;i>=1;i--){
        ok=solve(i);
        if(ok)
            break;
    }
    if(ok){
        for(int i=1;i<=n;i++){
            char t=a[i]+'a';
            cout<<t;
        }
        cout<<endl;
    }
    else
        cout<<"NO"<<endl;
    return 0;
}


#include<stdio.h>

int main(void)
{
	int n, p;
	char s[1010], ch[30], c;
	scanf("%d%d", &n, &p);
	for(int i = 0; i < 30; i++)
		ch[i] = 'a' + i;
	scanf("%s", s + 2);
	s[0] = 0;
	s[1] = 0;
	if(p == 1)
	{
	  printf("NO");
		return 0;
	}
	if(p == 2)
	{
	  if(n == 1)
		{
		  if(s[2] == 'a')
				printf("b");
			else
				printf("NO");
			return 0;
		}
		if(s[2] == 'a')
			printf("ba");
		else
			printf("NO");
		return 0;
	}
	for(int i = n + 1; i > 1; i--)// i'th - first changed
	{
	   c = s[i] + 1;
		 while(c != ch[p])
		 {
			 if(c != s[i - 1] && c != s[i - 2])
				 break;
			 c++;
		 }
		 if(c != ch[p])
		 {
			 s[i] = c;
		   for(int j = 2; j <= i; j++)
				 printf("%c", s[j]);
			 //printed i - 1, n - i + 1 more
       for(int j = i + 1; j < n + 2; j++)
			 {
			   c = 'a';
				 while(c == s[j - 1] || c == s[j - 2])
					 c++;
				 s[j] = c;
				 printf("%c", c);
			 }
			 return 0;
		 }
	}
	printf("NO");
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<sstream>
#include<queue>
#include<math.h>
#include<stdlib.h>
#include<stack>
#include<string.h>
#include<string>
#include<map>
#include<algorithm>
#include<time.h>
#include<set>
#include<vector>
#include<numeric>
#include<iomanip>
using namespace std;

#define All(a) a.begin(), a.end()
#define _2d(a,row,col,type) type**a=new type*[row]; for (int i=0;i<row;i++) a[i]=new type[col];
#define rep(i,n) for(int i=0;i<int(n);i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define repi(i,a,n) for(int i=int(a);i<int(n);i++)
#define clr(a, n) memset(a, n, sizeof(a));
#define scn(a,n) rep(i,n) cin>>a[i];
#define scn2(a,row,col) rep(i,row) rep(j,col) cin>>a[i][j];
#define prn(a,n) rep(i,n-1) cout<<a[i]<<" "; cout<<a[n-1]<<endl;
#define prn2(a,row,col) rep(i,row){rep(j,col-1) cout<<a[i][j]<<" "; cout<<a[i][col-1]<<endl;}
#define mp(a, b) make_pair(a, b)
#define Odd(x) x%2!=0
#define Even(x) x%2==0
#define Pi 3.14
#define INF 2000000000 // 2 billion

typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<int, string> is;
typedef vector<ii> vii;

#define FilesX
#define TimeX

/*---------------------------*/

int n, p;

bool sum(string &s, int i){
	if (s[i] == char('a' + p - 1) && !i)
		return false;

	s[i] = char('a' + (s[i] - 'a' + 1)%p);
	if (s[i] == 'a')
		return sum(s, i-1);
	return true;
}

int check(string s){
	rep(i, n-1){
		if (s[i] == s[i+1])
			return i+1;
		if (i < n-2 && s[i] == s[i+2])
			return i+2;
	}
	return -1;
}

void solution(){
	cin>>n>>p;
	string s;
	cin>>s;
	sum(s, n-1);
	int c;
	while (true){
		c = check(s);
		if (c == -1){
			cout<<s;
			return;
		}

		if (!sum(s, c)){
			cout<<"NO";
			return;
		}
	}
}

/*---------------------------*/
int main(){
	#ifdef Files
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	double beg=clock();

	ios::sync_with_stdio;
	solution();

	#ifdef Time
	cout << endl;
	double end=clock();
	printf("*** Total time = %.3f sec ***", (end - beg) / CLOCKS_PER_SEC);
	#endif
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<sstream>
#include<queue>
#include<math.h>
#include<stdlib.h>
#include<stack>
#include<string.h>
#include<string>
#include<map>
#include<algorithm>
#include<time.h>
#include<set>
#include<vector>
#include<numeric>
#include<iomanip>
using namespace std;

#define All(a) a.begin(), a.end()
#define _2d(a,row,col,type) type**a=new type*[row]; for (int i=0;i<row;i++) a[i]=new type[col];
#define rep(i,n) for(int i=0;i<int(n);i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define repi(i,a,n) for(int i=int(a);i<int(n);i++)
#define clr(a, n) memset(a, n, sizeof(a));
#define scn(a,n) rep(i,n) cin>>a[i];
#define scn2(a,row,col) rep(i,row) rep(j,col) cin>>a[i][j];
#define prn(a,n) rep(i,n-1) cout<<a[i]<<" "; cout<<a[n-1]<<endl;
#define prn2(a,row,col) rep(i,row){rep(j,col-1) cout<<a[i][j]<<" "; cout<<a[i][col-1]<<endl;}
#define mp(a, b) make_pair(a, b)
#define Odd(x) x%2!=0
#define Even(x) x%2==0
#define Pi 3.14
#define INF 2000000000 // 2 billion

typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<int, string> is;
typedef vector<ii> vii;

#define FilesX
#define TimeX

/*---------------------------*/

int n, p;

bool sum(string &s, int i){
	if (s[i] == char('a' + p - 1) && !i)
		return false;

	s[i] = char('a' + (s[i] - 'a' + 1)%p);
	if (s[i] == 'a')
		return sum(s, i-1);
	return true;
}

bool check(string s){
	rep(i, n-1){
		if (s[i] == s[i+1])
			return false;
		if (i < n-2 && s[i] == s[i+2])
			return false;
	}
	return true;
}

void solution(){
	cin>>n>>p;
	string s;
	cin>>s;
	while (true){
		if (!sum(s, n-1)){
			cout<<"NO";
			return;
		}

		if (check(s)){
			cout<<s;
			return;
		}
	}
}

/*---------------------------*/
int main(){
	#ifdef Files
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	double beg=clock();

	ios::sync_with_stdio;
	solution();

	#ifdef Time
	cout << endl;
	double end=clock();
	printf("*** Total time = %.3f sec ***", (end - beg) / CLOCKS_PER_SEC);
	#endif
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<sstream>
#include<queue>
#include<math.h>
#include<stdlib.h>
#include<stack>
#include<string.h>
#include<string>
#include<map>
#include<algorithm>
#include<time.h>
#include<set>
#include<vector>
#include<numeric>
#include<iomanip>
using namespace std;

#define All(a) a.begin(), a.end()
#define _2d(a,row,col,type) type**a=new type*[row]; for (int i=0;i<row;i++) a[i]=new type[col];
#define rep(i,n) for(int i=0;i<int(n);i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define repi(i,a,n) for(int i=int(a);i<int(n);i++)
#define clr(a, n) memset(a, n, sizeof(a));
#define scn(a,n) rep(i,n) cin>>a[i];
#define scn2(a,row,col) rep(i,row) rep(j,col) cin>>a[i][j];
#define prn(a,n) rep(i,n-1) cout<<a[i]<<" "; cout<<a[n-1]<<endl;
#define prn2(a,row,col) rep(i,row){rep(j,col-1) cout<<a[i][j]<<" "; cout<<a[i][col-1]<<endl;}
#define mp(a, b) make_pair(a, b)
#define Odd(x) x%2!=0
#define Even(x) x%2==0
#define Pi 3.14
#define INF 2000000000 // 2 billion

typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<int, string> is;
typedef vector<ii> vii;

#define FilesX
#define TimeX

/*---------------------------*/

int n, p;

bool sum(string &s, int i){
	if (s[i] == char('a' + p - 1) && !i)
		return false;

	s[i] = char('a' + (s[i] - 'a' + 1)%p);
	if (s[i] == 'a')
		return sum(s, i-1);
	return true;
}

int check(string s){
	rep(i, n-1){
		if (s[i] == s[i+1])
			return i+1;
		if (i < n-2 && s[i] == s[i+2])
			return i+2;
	}
	return -1;
}

void solution(){
	cin>>n>>p;
	string s;
	cin>>s;
	if (!sum(s, n-1)){
		cout<<"NO";
		return;
	}
	int c;
	while (true){
		c = check(s);
		if (c == -1){
			cout<<s;
			return;
		}

		if (!sum(s, c)){
			cout<<"NO";
			return;
		}
	}
}

/*---------------------------*/
int main(){
	#ifdef Files
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	double beg=clock();

	ios::sync_with_stdio;
	solution();

	#ifdef Time
	cout << endl;
	double end=clock();
	printf("*** Total time = %.3f sec ***", (end - beg) / CLOCKS_PER_SEC);
	#endif
	return 0;
}


#include<iostream>
#include<vector>
#include<math.h>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
		int n,p;
		int a[1200];
		bool b[26]={false};
		cin>>n>>p;
		p--;
		vector <char> c;
		string s;
		cin>>s;
		bool ok=false;
	int nom=-1;

		for(int i=n-1; i>=0 && !ok; i--){
			for(int j=s[i]-'a'+1; j<=p; j++){
				if( (i-1<0 || s[i-1]!=char('a'+j)) && (i-2<0 || s[i-2]!=char('a'+j)) ){
					nom=i;
					ok=true;
					s[i]=char('a'+j);
					break;
				}
			}
		}
		if(nom==-1){
			cout<<"NO";
			return 0;
		}

		for(int i=nom+1; i<s.size(); i++){
			for(int j=0; j<=p; j++){
				if( (i-1<0 || s[i-1]!=char('a'+j)) && (i-2<0 || s[i-2]!=char('a'+j)) ){
					s[i]=char('a'+j);
					break;
				}
				if(j==p){
					cout<<"NO";
					return 0;
				}
			}
		}

		cout<<s;

}


#include<iostream>
#include<vector>
#include<math.h>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
		int n,p;
		int a[1200];
		bool b[26]={false};
		cin>>n>>p;
		p--;
		vector <char> c;
		string s;
		cin>>s;
		bool ok=false;
	int nom=-1;

		for(int i=n-1; i>=0 && !ok; i--){
			for(int j=s[i]-'a'+1; j<=p; j++){
				if( (i-1<0 || s[i-1]!=char('a'+j)) && (i-2<0 || s[i-2]!=char('a'+j)) ){
					nom=i;
					ok=true;
					s[i]=char('a'+j);
					break;
				}
			}
		}
		if(nom==-1){
			cout<<"NO";
			return 0;
		}

		for(int i=nom+1; i<s.size(); i++){
			for(int j=0; j<=p; j++){
				if( (i-1<0 || s[i-1]!=char('a'+j)) && (i-2<0 || s[i-2]!=char('a'+j)) ){
					s[i]=char('a'+j);
					break;
				}
				if(j==p-1){
					cout<<"NO";
					return 0;
				}
			}
		}

		cout<<s;

}


#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream ff("file.txt");
	int n, p;
	ff>>n>>p;
	n+=4;
	char *s2 = new char[n];
	s2[0]='*';
	s2[1]='#';
	s2[n-1]='=';
	s2[n-2]='+';
	for(int i=2; i<n-2; i++)  ff>>s2[i];
	int Max = 97+p-1;
	//cout<<(char)Max<<endl;
	char C;
	int idx;
	bool b2=false;
	for(int i=n-3; i>=2; i--)
	{
		C =((int)s2[i])+1;
line1:
		//cout<<C<<endl;
		if(C>(char)Max) { continue; }
		if(C==s2[i-1] || C==s2[i-2])
		{
			if(C==(char)Max) continue;
			C=(int)++C;
			goto line1;
		}
		else
		{
			s2[i]=C;
			idx=i;
			b2=true;
			break;
		}
	}
	if(b2==false)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int kol=0;
	/*
	for(int i=2; i<n-2; i++)
	{
		cout<<s2[i];
	}
cout<<endl;
*/
	for(int i=idx+1; i<n-2; i++)
	{
		kol=0;
line2:
		//cout<<C<<endl;
		//cout<<(char)Max<<endl;
		if(kol==p)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		kol++;
		C = (int)++C;
		if(C>(char)Max)
		{
			C='a';
			//cout<<C<<endl;
		}
		if(C==s2[i-1] || C==s2[i-2])
		{
			goto line2;
		}
		else
		{
			s2[i]=C;
			idx=i;
			s2[i+1]='a';
			//break;
		}

	}

	for(int i=2; i<n-2; i++)
	{
		cout<<s2[i];
	}

	return 0;
}


#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream ff("file.txt");
	int n, p;
	cin>>n>>p;
	n+=4;
	char *s2 = new char[n];
	s2[0]='*';
	s2[1]='#';
	s2[n-1]='=';
	s2[n-2]='+';
	for(int i=2; i<n-2; i++)  cin>>s2[i];
	int Max = 97+p-1;
	//cout<<(char)Max<<endl;
	char C;
	int idx;
	bool b2=false;
	for(int i=n-3; i>=2; i--)
	{
		C =((int)s2[i])+1;
line1:
		//cout<<C<<endl;
		if(C>(char)Max) { continue; }
		if(C==s2[i-1] || C==s2[i-2])
		{
			if(C==(char)Max) continue;
			C=(int)++C;
			goto line1;
		}
		else
		{
			s2[i]=C;
			idx=i;
			b2=true;
			break;
		}
	}
	if(b2==false)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int kol=0;

	//s2[idx+1]='a';
	/*
	for(int i=2; i<n-2; i++)
	{
		cout<<s2[i];
	}
	cout<<endl<<endl;*/
	for(int i=idx+1; i<n-2; i++)
	{
		kol=0;
		C=(char)96;
line2:
		//cout<<C<<endl;
		//cout<<(char)Max<<endl;
		if(kol==p)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		kol++;
		C = (int)++C;
		if(C>(char)Max)
		{
			C='a';
			//cout<<C<<endl;
		}
		//cout<<s2[i-1]<<' '<<s2[i-2]<<' '<<C<<endl;
		if(C==s2[i-1] || C==s2[i-2])
		{
			goto line2;
		}
		else
		{
			s2[i]=C;
			idx=i;
			s2[i+1]='a';
			//break;
		}

	}

	for(int i=2; i<n-2; i++)
	{
		cout<<s2[i];
	}

	return 0;
}


#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream ff("file.txt");
	int n, p;
	cin>>n>>p;
	n+=4;
	char *s2 = new char[n];
	s2[0]='*';
	s2[1]='#';
	s2[n-1]='=';
	s2[n-2]='+';
	for(int i=2; i<n-2; i++)  cin>>s2[i];
	int Max = 97+p-1;
	char C;
	int idx;
	bool b2=false;
	for(int i=n-3; i>=2; i--)
	{
		C =((int)s2[i])+1;
		if(C>(char)Max) { continue; }
		while(C==s2[i-1] || C==s2[i-2])
		{
			if(C==(char)Max) continue;
			C=(int)++C;
		}
		s2[i]=C;
		idx=i;
		b2=true;
		break;
	}
	if(b2==false)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int kol=0;
	for(int i=idx+1; i<n-2; i++)
	{
		kol=0;
		C=(char)96;
		do
		{
			if(kol==p)
			{
				cout<<"NO"<<endl;
				return 0;
			}
			kol++;
			C = (int)++C;
			if(C>(char)Max)  C='a';
		}
		while(C==s2[i-1] || C==s2[i-2]);
		s2[i]=C;
		idx=i;
		s2[i+1]='a';
	}
	for(int i=2; i<n-2; i++) {	cout<<s2[i]; }
	return 0;
}


#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream ff("file.txt");
	int n, p;
	cin>>n>>p;
	n+=4;
	char *s2 = new char[n];
	s2[0]='*';
	s2[1]='#';
	s2[n-1]='=';
	s2[n-2]='+';
	for(int i=2; i<n-2; i++)  cin>>s2[i];
	int Max = 97+p-1;
	char C;
	int idx;
	bool b2=false;
	for(int i=n-3; i>=2; i--)
	{
		C =((int)s2[i])+1;
		if(C>(char)Max) { continue; }
		while(C==s2[i-1] && C==s2[i-2])
		{
			if(C==(char)Max) continue;
			C=(int)++C;
		}
		s2[i]=C;
		idx=i;
		b2=true;
		break;
	}
	if(b2==false)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int kol=0;
	for(int i=idx+1; i<n-2; i++)
	{
		kol=0;
		C=(char)96;
		do
		{
			if(kol==p)
			{
				cout<<"NO"<<endl;
				return 0;
			}
			kol++;
			C = (int)++C;
			if(C>(char)Max)  C='a';
		}
		while(C==s2[i-1] && C==s2[i-2]);
		s2[i]=C;
		idx=i;
		s2[i+1]='a';
	}
	for(int i=2; i<n-2; i++) {	cout<<s2[i]; }
	return 0;
}


#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream ff("file.txt");
	int n, p;
	cin>>n>>p;
	n+=4;
	char *s2 = new char[n];
	s2[0]='*';
	s2[1]='#';
	s2[n-1]='=';
	s2[n-2]='+';
	for(int i=2; i<n-2; i++)  cin>>s2[i];
	int Max = 97+p-1;
	//cout<<(char)Max<<endl;
	char C;
	int idx;
	bool b2=false;
	for(int i=n-3; i>=2; i--)
	{
		C =((int)s2[i])+1;
line1:
		//cout<<C<<endl;
		if(C>(char)Max) { continue; }
		if(C==s2[i-1] || C==s2[i-2])
		{
			if(C==(char)Max) continue;
			C=(int)++C;
			goto line1;
		}
		else
		{
			s2[i]=C;
			idx=i;
			b2=true;
			break;
		}
	}
	if(b2==false)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int kol=0;
	/*
	for(int i=2; i<n-2; i++)
	{
		cout<<s2[i];
	}
cout<<endl;
*/
	for(int i=idx+1; i<n-2; i++)
	{
		kol=0;
line2:
		//cout<<C<<endl;
		//cout<<(char)Max<<endl;
		if(kol==p)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		kol++;
		C = (int)++C;
		if(C>(char)Max)
		{
			C='a';
			//cout<<C<<endl;
		}
		if(C==s2[i-1] || C==s2[i-2])
		{
			goto line2;
		}
		else
		{
			s2[i]=C;
			idx=i;
			s2[i+1]='a';
			//break;
		}

	}

	for(int i=2; i<n-2; i++)
	{
		cout<<s2[i];
	}

	return 0;
}


#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream ff("file.txt");
	int n, p;
	cin>>n>>p;
	n+=4;
	char *s2 = new char[n];
	s2[0]='*';
	s2[1]='#';
	s2[n-1]='=';
	s2[n-2]='+';
	for(int i=2; i<n-2; i++)  cin>>s2[i];
	int Max = 97+p-1;
	//cout<<(char)Max<<endl;
	char C;
	int idx;
	bool b2=false;
	for(int i=n-3; i>=2; i--)
	{
line1:

		if(s2[i]>=(char)Max) continue;
		C = (int)++s2[i];

		//cout<<C<<endl;
		if(C==s2[i-1] || C==s2[i-2])
		{

			goto line1;
		}
		else
		{
			s2[i]=C;
			idx=i;
			b2=true;
			break;
		}
		//cout<<C<<endl;
	}
	if(b2==false)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int kol=0;
	for(int i=idx+1; i<n-2; i++)
	{
		kol=0;
line2:
		if(kol==p)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		kol++;
		C = (int)++s2[i];
		if(C>(char)Max)
		{
			C='a';
		}
		if(C==s2[i+1] || C==s2[i+2] || C==s2[i-1] || C==s2[i-2])
		{
			goto line2;
		}
		else
		{
			s2[i]=C;
			idx=i;
			s2[i+1]='a';
			//break;
		}
		//cout<<C<<endl;
	}

	for(int i=2; i<n-2; i++)
	{
		cout<<s2[i];
	}

	return 0;
}


#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream ff("file.txt");
	int n, p;
	ff>>n>>p;
	n+=4;
	char *s2 = new char[n];
	s2[0]='*';
	s2[1]='#';
	s2[n-1]='=';
	s2[n-2]='+';
	for(int i=2; i<n-2; i++)  ff>>s2[i];
	int Max = 97+p-1;
	//cout<<(char)Max<<endl;
	char C;
	int idx;
	bool b2=false;
	for(int i=n-3; i>=2; i--)
	{
line1:

		if(s2[i]>=(char)Max) continue;
		C = (int)++s2[i];

		//cout<<C<<endl;
		if(C==s2[i-1] || C==s2[i-2])
		{
			goto line1;
		}
		else
		{
			s2[i]=C;
			idx=i;
			b2=true;
			break;
		}
		//cout<<C<<endl;
	}
	if(b2==false)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int kol=0;
	for(int i=idx+1; i<n-2; i++)
	{
		kol=0;
line2:
		if(kol==p)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		kol++;
		C = (int)++s2[i];
		if(C>(char)Max)
		{
			C='a';
		}
		if(C==s2[i+1] || C==s2[i+2] || C==s2[i-1] || C==s2[i-2])
		{
			goto line2;
		}
		else
		{
			s2[i]=C;
			idx=i;
			break;
		}
		//cout<<C<<endl;
	}

	for(int i=2; i<n-2; i++)
	{
		cout<<s2[i];
	}

	return 0;
}