#include <stdio.h>
#include <stdlib.h>
using namespace std;

int n,i,j,k,c;

int main()
{
	scanf("%d",&n);
	if(n&1){printf("-1\n");return 0;}
	n/=2;
	for(i=1;i<=n;++i)
	{
		c^=1;
		for(j=1;j<=n;++j)
		{
			for(k=1;k<=n;++k)if(c)printf("ww");else printf("bb");printf("\n");
			for(k=1;k<=n;++k)if(c)printf("ww");else printf("bb");printf("\n");
		}
		printf("\n");
		c^=1;
		for(j=1;j<=n;++j)
		{
			for(k=1;k<=n;++k)if(c)printf("ww");else printf("bb");printf("\n");
			for(k=1;k<=n;++k)if(c)printf("ww");else printf("bb");printf("\n");
		}
		printf("\n");
	}
}


#include <stdio.h>
#include <stdlib.h>
using namespace std;

int n,i,j,k,c;

int main()
{
	scanf("%d",&n);
	if(n&1){printf("-1\n");return 0;}
	n/=2;
	for(i=1;i<=n;++i)
	{
		c^=1;
		for(j=1;j<=n;++j)
		{
			c^=1;
			for(k=1;k<=n;++k)if(c^(k&1))printf("ww");else printf("bb");printf("\n");
			for(k=1;k<=n;++k)if(c^(k&1))printf("ww");else printf("bb");printf("\n");
		}
		printf("\n");
		c^=1;
		for(j=1;j<=n;++j)
		{
			c^=1;
			for(k=1;k<=n;++k)if(c^(k&1))printf("ww");else printf("bb");printf("\n");
			for(k=1;k<=n;++k)if(c^(k&1))printf("ww");else printf("bb");printf("\n");
		}
		printf("\n");
	}
}


#include <stdio.h>
#include <stdlib.h>
using namespace std;

int n,i,j,k,c;

int main()
{
	scanf("%d",&n);
	if(n&1){printf("-1\n");return 0;}
	n/=2;
	for(i=1;i<=n;++i)
	{
		c=0;
		for(j=1;j<=n;++j)
		{
			c^=1;
			for(k=1;k<=n;++k)if(c^(k&1))printf("ww");else printf("bb");printf("\n");
			for(k=1;k<=n;++k)if(c^(k&1))printf("ww");else printf("bb");printf("\n");
		}
		printf("\n");
		c=1;
		for(j=1;j<=n;++j)
		{
			c^=1;
			for(k=1;k<=n;++k)if(c^(k&1))printf("ww");else printf("bb");printf("\n");
			for(k=1;k<=n;++k)if(c^(k&1))printf("ww");else printf("bb");printf("\n");
		}
		printf("\n");
	}
}


//In The Name Of ALLAH

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>

using namespace std ;

int main()
{
	int n ;
	cin>>n ;
	if(n%2==1)
	{
		cout<<-1;
		return 0 ;
	}
	int t=0,q,qq;
	for(int s=1;s<=n;s++)
	{
		if(s%2==0)
		{q=1;qq=0;}
		else
		{qq=1;q=0;}
		for(int j=1;j<=n;j++)
		{
			t=0;
			for(int i=1;i<=n;i+=2)
			{
				if(j%2==1)
				{
						t++;
					if(t%2==q)
						cout<<"bb";
						else
						cout<<"ww";
				}
				else
				{

						t++;
					if(t%2==qq)
						cout<<"bb";
						else
						cout<<"ww";
				}

			}
			cout<<endl ;
		}
		cout<<endl ;
	}
	cin>> n ;
	return 0 ;
}


//In The Name Of ALLAH

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>

using namespace std ;

int main()
{
	int n ;
	cin>>n ;
	if(n%2==1)
	{
		cout<<-1;
		return 0 ;
	}
	int t=0,q,qq;
	for(int s=0;s<n;s++)
	{
		if(s%4==0 || s%4==1)
		{q=1;qq=0;}
		else
		{qq=1;q=0;}

		for(int j=1;j<=n;j++)
		{
			t=0;
			for(int i=1;i<=n;i+=2)
			{
				if(j%2==1)
				{
						t++;
					if(t%2==q)
						cout<<"bb";
						else
						cout<<"ww";
				}
				else
				{

						t++;
					if(t%2==qq)
						cout<<"bb";
						else
						cout<<"ww";
				}

			}
			cout<<endl ;
		}
		cout<<endl ;
	}
	cin>> n ;
	return 0 ;
}


//In The Name Of ALLAH

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>

using namespace std ;

int main()
{
	int n ;
	cin>>n ;
	if(n%2==1)
	{
		cout<<-1;
		return 0 ;
	}

	for(int s=1;s<=n;s++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int i=1;i<=n;i++)
			{
				if(s%2==0)
				{
						if(j%2==i%2)
						cout<<"w";
						else
						cout<<"b";
				}
				else
				{
						if(j%2!=i%2)
						cout<<"w";
						else
						cout<<"b";
				}
			}
			cout<<endl ;
		}
		cout<<endl ;
	}
	cin>> n ;
	return 0 ;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <time.h>
#include <map>
#include <stack>
#include <string>
#include <climits>
#include <ctime>
#include <fstream>
#include <sstream>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define LD long double
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define DB(x) cout<<"\n"<<#x<<" = "<<(x)<<"\n";
#define CL(a,b) memset(a,b,sizeof(a))
#define GOLD ((1+sqrt(5))/2)
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps (char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
void swapi(int *a,int *b){int temp;temp=*a;*a=*b;*b=temp;}
ULL gcd(ULL a,ULL b){if(a==0)return b;if(b==0)return a;if(a==1||b==1)return 1;
if(a==b)return a;if(a>b)return gcd(b,a%b);else return gcd(a,b%a);}
int main()
{
    int N;
    cin>>N;
    if(N==1)
	    cout<<-1<<endl;
    else if(N==2)
    {
	   cout<<"bb"<<endl;
	   cout<<"ww"<<endl;
	   cout<<endl;
	   cout<<"bb"<<endl;
	   cout<<"ww"<<endl;
    }
    else
    {
	    FOR(i,0,N)
	    {
		    FOR(j,0,N)
		    {
			    FOR(k,0,N)
			    {
				    if((i+j)%2)
					    cout<<"w";
				    else
					    cout<<"b";
			    }
			    cout<<endl;
		    }
		    cout<<endl;
	    }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <time.h>
#include <map>
#include <stack>
#include <string>
#include <climits>
#include <ctime>
#include <fstream>
#include <sstream>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define LD long double
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define DB(x) cout<<"\n"<<#x<<" = "<<(x)<<"\n";
#define CL(a,b) memset(a,b,sizeof(a))
#define GOLD ((1+sqrt(5))/2)
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps (char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
void swapi(int *a,int *b){int temp;temp=*a;*a=*b;*b=temp;}
ULL gcd(ULL a,ULL b){if(a==0)return b;if(b==0)return a;if(a==1||b==1)return 1;
if(a==b)return a;if(a>b)return gcd(b,a%b);else return gcd(a,b%a);}
int main()
{
    int N;
    cin>>N;
    if(N&1)
	    cout<<-1<<endl;
    else if(N==2)
    {
	   cout<<"bb"<<endl;
	   cout<<"ww"<<endl;
	   cout<<endl;
	   cout<<"bb"<<endl;
	   cout<<"ww"<<endl;
    }
    else
    {
	    FOR(i,0,N)
	    {
		    FOR(j,0,N)
		    {
			    FOR(k,0,N)
			    {
				    if((i+j)%2)
					    cout<<"w";
				    else
					    cout<<"b";
			    }
			    cout<<endl;
		    }
		    cout<<endl;
	    }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <time.h>
#include <map>
#include <stack>
#include <string>
#include <climits>
#include <ctime>
#include <fstream>
#include <sstream>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define LD long double
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define DB(x) cout<<"\n"<<#x<<" = "<<(x)<<"\n";
#define CL(a,b) memset(a,b,sizeof(a))
#define GOLD ((1+sqrt(5))/2)
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps (char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
void swapi(int *a,int *b){int temp;temp=*a;*a=*b;*b=temp;}
ULL gcd(ULL a,ULL b){if(a==0)return b;if(b==0)return a;if(a==1||b==1)return 1;
if(a==b)return a;if(a>b)return gcd(b,a%b);else return gcd(a,b%a);}
int main()
{
    int N;
    cin>>N;
    if(N==1)
	    cout<<-1<<endl;
    else if(N==2)
    {
	   cout<<"ww"<<endl;
	   cout<<"bb"<<endl;
	   cout<<endl;
	   cout<<"bb"<<endl;
	   cout<<"ww"<<endl;
    }
    else
    {
	    FOR(i,0,N)
	    {
		    FOR(j,0,N)
		    {
			    FOR(k,0,N)
			    {
				    if((i+j)%2)
					    cout<<"w";
				    else
					    cout<<"b";
			    }
			    cout<<endl;
		    }
		    cout<<endl;
	    }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <time.h>
#include <map>
#include <stack>
#include <string>
#include <climits>
#include <ctime>
#include <fstream>
#include <sstream>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define LD long double
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define DB(x) cout<<"\n"<<#x<<" = "<<(x)<<"\n";
#define CL(a,b) memset(a,b,sizeof(a))
#define GOLD ((1+sqrt(5))/2)
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps (char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
void swapi(int *a,int *b){int temp;temp=*a;*a=*b;*b=temp;}
ULL gcd(ULL a,ULL b){if(a==0)return b;if(b==0)return a;if(a==1||b==1)return 1;
if(a==b)return a;if(a>b)return gcd(b,a%b);else return gcd(a,b%a);}
int main()
{
    int N;
    cin>>N;
    if(N==1)
	    cout<<-1<<endl;
    else
    {
	    FOR(i,0,N)
	    {
		    FOR(j,0,N)
		    {
			    FOR(k,0,N)
			    {
				    cout<<"w";
			    }
			    cout<<endl;
		    }
		    cout<<endl;
	    }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <time.h>
#include <map>
#include <stack>
#include <string>
#include <climits>
#include <ctime>
#include <fstream>
#include <sstream>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define LD long double
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define DB(x) cout<<"\n"<<#x<<" = "<<(x)<<"\n";
#define CL(a,b) memset(a,b,sizeof(a))
#define GOLD ((1+sqrt(5))/2)
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps (char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
void swapi(int *a,int *b){int temp;temp=*a;*a=*b;*b=temp;}
ULL gcd(ULL a,ULL b){if(a==0)return b;if(b==0)return a;if(a==1||b==1)return 1;
if(a==b)return a;if(a>b)return gcd(b,a%b);else return gcd(a,b%a);}
int x[101][101];
int main()
{
    int N;
    cin>>N;
    if(N&1)
	    cout<<-1<<endl;
    else if(N==2)
    {
	   cout<<"bb"<<endl;
	   cout<<"ww"<<endl;
	   cout<<endl;
	   cout<<"bb"<<endl;
	   cout<<"ww"<<endl;
    }
    else
    {
	    int xi = 0;
	    int res = 0;
	    while(xi<N){
		    FOR(j,xi,N-xi)
		    {
			    FOR(k,xi,N-xi)
			    {
				    x[j][k] = res;
			    }
		    }
		    res^=1;
		    xi+=1;
	    }
	    FOR(k,0,N){
		    FOR(i,0,N)
		    {
			    FOR(j,0,N)
			    {
				    if(k&1)
				    {
					    if(x[i][j]==0)
						    cout<<"w";
					    else
						    cout<<"b";
				    }
				    else
				    {
					    if(x[i][j]==1)
						    cout<<"w";
					    else
						    cout<<"b";
				    }
			    }
			    cout<<endl;
		    }
		    cout<<endl;
	    }
    }
    return 0;
}


#include<iostream>
using namespace std;
int k;
const int maX=100;
bool a[maX][maX];
int main()
{
		cin>>k;
		if(k%2==1)
		{
				cout<<-1<<endl;
				return 0;
		}
		for(int j=0;j<k;j++)
		{
				a[0][j]=j%2;
				a[k-1][j]=!(j%2);
		}
		for(int i=1;i<(k-1);i++)
				for(int j=0;j<(k/2);j++)
				{
						bool q=!(i%2);
						a[i][(k/2)*q+j]=1;
				}

		for(int w=k;w>0;w--)
		{
				for(int i=0;i<k;i++)
				{
						for(int j=0;j<k;j++)
						{
								if(a[i][j])
										cout<<"b";
								else
										cout<<"w";
						}
						cout<<endl;
				}
				cout<<endl;
		}
		return 0;
}


#include<iostream>
using namespace std;
int k;
const int maX=100;
bool a[maX][maX];
int main()
{
		cin>>k;
		if(k%2==1)
		{
				cout<<-1<<endl;
				return 0;
		}
		cout<<5/0<<endl;
		for(int j=0;j<k;j++)
				a[0][j]=j%2;
		for(int i=1;i<k;i++)
				for(int j=0;j<(k/2);j++)
				{
						bool q=!(i%2);
						a[i][(k/2)*q+j]=1;
				}

		for(int w=k;w>0;w--)
		{
				for(int i=0;i<k;i++)
				{
						for(int j=0;j<k;j++)
						{
								if(a[i][j])
										cout<<"b";
								else
										cout<<"w";
						}
						cout<<endl;
				}
				cout<<endl;
		}
		return 0;
}


#include<iostream>
using namespace std;
int k;
const int maX=100;
bool a[maX][maX];
int main()
{
		cin>>k;
		if((k%2)==1)
		{
				cout<<-1<<endl;
				return 0;
		}
		for(int w=0;w<k/2;w++)
		{
				for(int q=0;q<2;q++)
				{
						for(int i=0;i<k;i++)
						{
								for(int j=0;j<(k/2);j++)
								{
										if((w+i+j)%2)
												cout<<"bb";
										else
												cout<<"ww";
								}
								cout<<endl;
						}
						cout<<endl;
				}
		}
		return 0;

}


#include<iostream>
using namespace std;
int k;
const int maX=100;
bool a[maX][maX];
int main()
{
		cin>>k;
		if(k%2==1)
		{
				cout<<5/0<<endl;
				return 0;
		}
		for(int j=0;j<k;j++)
				a[0][j]=j%2;
		for(int i=1;i<k;i++)
				for(int j=0;j<(k/2);j++)
				{
						bool q=!(i%2);
						a[i][(k/2)*q+j]=1;
				}

		for(int w=k;w>0;w--)
		{
				for(int i=0;i<k;i++)
				{
						for(int j=0;j<k;j++)
						{
								if(a[i][j])
										cout<<"b";
								else
										cout<<"w";
						}
						cout<<endl;
				}
				cout<<endl;
		}
		return 0;
}


#include<iostream>
using namespace std;
int k;
const int maX=100;
bool a[maX][maX];
int main()
{
		cin>>k;
		if(k%2==1)
		{
				cout<<-1<<endl;
				return 0;
		}
		for(int w=0;w<k;w++)
		{
				for(int i=0;i<k;i++)
				{
						for(int j=0;j<(k/2);j++)
						{
								if((i+j)%2)
										cout<<"bb";
								else
										cout<<"ww";
						}
						cout<<endl;
				}
				cout<<endl;
		}
		return 0;

}


#include<iostream>
using namespace std;
int k;
const int maX=100;
bool a[maX][maX];
int main()
{
		cin>>k;
		if(k%2==1)
		{
				cout<<"-1"<<endl;
				return 0;
		}
		for(int j=0;j<k;j++)
				a[0][j]=j%2;
		for(int i=1;i<k;i++)
				for(int j=0;j<(k/2);j++)
				{
						bool q=!(i%2);
						a[i][(k/2)*q+j]=1;
				}

		for(int w=k;w>0;w--)
		{
				for(int i=0;i<k;i++)
				{
						for(int j=0;j<k;j++)
						{
								if(a[i][j])
										cout<<"b";
								else
										cout<<"w";
						}
						cout<<endl;
				}
				cout<<endl;
		}
		return 0;
}


#include <iostream>

using namespace std;

int k;

int main()
{
  cin >> k;
  if (k == 2) cout << "bb\nww\n\nbb\nww";
  else cout << -1;
  return 0;
}


#include <iostream>

using namespace std;

const int max_dim = 112;

int k, a[max_dim][max_dim];

int main()
{
  for (int i = 0; i < max_dim; i += 2)
    for (int j = 0; j < max_dim; j += 2)
      a[i][j] = a[i + 1][j] = a[i][j + 1] = a[i + 1][j + 1] = (((i / 2) & 1) + ((j / 2) & 1)) & 1;
  cin >> k;
  if (k & 1) cout << -1;
  else
    for (int l = 0; l < k; l++)
    {
      for (int i = 0; i < k; i++)
      {
        for (int j = 0; j < k; j++)
          cout << (a[i][j] ^ (l & 1) ? 'b' : 'w');
        cout << endl;
      }
      cout << endl;
    }
  return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
using namespace std;
#define X first
#define Y second
typedef long long lld;
char g[110][110];
int main()
{
	int n;
	scanf("%d",&n);
	if(n&1)
		printf("-1\n");
	else
	{
		for(int k=0;k<n;k++)
		{
			for(int i=0;i<n;i+=2)
				for(int j=0;j<n;j+=2)
				{
					int flag=(i/2+j/2+k)&1;
					if(flag)
						g[i][j]=g[i+1][j]=g[i][j+1]=g[i+1][j+1]='B';
					else
						g[i][j]=g[i+1][j]=g[i][j+1]=g[i+1][j+1]='W';
				}
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<n;j++)
					printf("%c",g[i][j]);
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
using namespace std;
#define X first
#define Y second
typedef long long lld;
char g[110][110];
int main()
{
	int n;
	scanf("%d",&n);
	if(n&1)
		printf("-1\n");
	else
	{
		for(int k=0;k<n;k++)
		{
			for(int i=0;i<n;i+=2)
				for(int j=0;j<n;j+=2)
				{
					int flag=(i/2+j/2+k)&1;
					if(flag)
						g[i][j]=g[i+1][j]=g[i][j+1]=g[i+1][j+1]='b';
					else
						g[i][j]=g[i+1][j]=g[i][j+1]=g[i+1][j+1]='w';
				}
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<n;j++)
					printf("%c",g[i][j]);
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define rep(i,s,t) for (int i = s; i <= t; ++i)
#define per(i,s,t) for (int i = s; i >= t; --i)
using namespace std;
int n;
int f1, f2;
char ch, s[2];
int main()
{
	s[0] = 'b'; s[1] = 'w';
	scanf("%d", &n);
	if (n&1) { printf("-1\n"); return 0; }
	rep(i,1,n)
	{
		f1 = ((i+1)>>1)&1;
		rep(j,1,n)
		{
			rep(k,1,n>>1)
			{
				f2 = (j+k)&1;
				printf("%c%c", s[f1^f2], s[f1^f2]);
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define rep(i,s,t) for (int i = s; i <= t; ++i)
#define per(i,s,t) for (int i = s; i >= t; --i)
using namespace std;
int n;
bool f1, f2;
char ch;
int main()
{
	scanf("%d", &n);
	if (n&1) { printf("-1\n"); return 0; }
	rep(i,1,n)
	{
		if (i%4 < 2) f1 = 0; else f1 = 1;
		rep(j,1,n)
		{
			if (j%4 < 2) f2 = 0; else f2 = 1;
			if (f1^f2) ch = 'w'; else ch = 'b';
			rep(k,1,n) printf("%c", ch); printf("\n");
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <ctime>

using namespace std;

#ifdef WIN32
  #define LLD "%I64d"
#else
  #define LLD "%lld"
#endif

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll rdtsc() {
  ll tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}

inline int myrand() {
  return abs((rand() << 15) ^ rand());
}

inline int rnd(int x) {
  return myrand() % x;
}

#define TASKNAME "text"
#define pb push_back
#define mp make_pair
#define EPS (1e-9)
#define INF ((int)1e9)
#define sqr(x) ((x) * (x))
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define sz(x) ((int)(x).size())

const char chars[2] = {'b', 'w'};

bool solve() {
  int n;
  if (scanf("%d", &n) < 1)
    return 0;
  if (n & 1) {
    printf("-1\n");
    return 1;
  }

  for (int i = 0; i < n; ++i) {
    for (int y = 0; y < n; ++y) {
      for (int x = 0; x < n; ++x) {
        int val = min(min(y, n - 1 - y), min(x, n - 1 - x));
        int col = (i & 1) ^ (val & 1);
        printf("%c", chars[col]);
      }
      printf("\n");
    }
    if (i != n - 1)
      printf("\n");
  }
  return 1;
}

int main() {
  srand(rdtsc());
#ifdef DEBUG
  freopen(TASKNAME".in", "r", stdin);
  freopen(TASKNAME".out", "w", stdout);
#endif

  while (1) {
    if (!solve())
      break;
    #ifdef DEBUG
      eprintf("%.18lf\n", (double)clock() / CLOCKS_PER_SEC);
    #endif
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector< ii > vii;

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3F3F3F3F3FLL
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define LSONE(s) ((s)&(-s)) //LASTBIT
#define DEG_to_RAD(X)   (X * PI / 180)
#define F first
#define S second
#define PI 2*acos(0)

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

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

void arquivo()
{
	freopen("","r",stdin);
	freopen("","w",stdout);
}

int main()
{
	//ios::sync_with_stdio(0);
	int k; cin >> k;
	if( k & 1 ) puts("-1");
	else
	{
		int q = k;
		while(q--){
			for(int i=0;i<k;++i){
				for(int j=0;j<k;++j){
					int foo = min(j, min(i, min(k-j-1, k-i-1)));
					if( foo%2 == i%2 ) printf("w");
					else printf("b");
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector< ii > vii;

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3F3F3F3F3FLL
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define LSONE(s) ((s)&(-s)) //LASTBIT
#define DEG_to_RAD(X)   (X * PI / 180)
#define F first
#define S second
#define PI 2*acos(0)

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

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

void arquivo()
{
	freopen("","r",stdin);
	freopen("","w",stdout);
}

int main()
{
	//ios::sync_with_stdio(0);
	int k; cin >> k;
	if( k & 1 ) puts("-1");
	else
	{
		int q = k;
		while(q--){
			for(int i=0;i<k;++i){
				for(int j=0;j<k;++j){
					int foo = min(j, min(i, min(k-j-1, k-i-1)));
					if( foo%2 == q%2 ) printf("w");
					else printf("b");
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector< ii > vii;

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3F3F3F3F3FLL
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define LSONE(s) ((s)&(-s)) //LASTBIT
#define DEG_to_RAD(X)   (X * PI / 180)
#define F first
#define S second
#define PI 2*acos(0)

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

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

void arquivo()
{
	freopen("","r",stdin);
	freopen("","w",stdout);
}

int main()
{
	//ios::sync_with_stdio(0);
	ll k; cin >> k;
	if( k == 1 ) puts("-1");
	else if( k == 2 ){
		int q = k;
		while(q--){
			for(int i=0;i<k;++i){
				for(int j=0;j<k;++j){
					if( i%2==0 ) printf("w");
					else printf("b");
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	else
	{
		int q = k;
		while(q--){
			for(int i=0;i<k;++i){
				for(int j=0;j<k;++j){
					if( (q+i)%2==0 ) printf("w");
					else printf("b");
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}


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

#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define pii pair < int , int >
#define ll long long

const int N = 200;
int k, mark[N][N];

void f(int val){

	memset(mark, 1-val, sizeof mark);

	for(int i = 0; i < k; i++)
		for(int j = i; j < k-i; j++)
			if(i%2 == 0)
				mark[i][j] = val;
	for(int i = k-1; i > 0; i--)
		for(int j = i; j >= k-1-i; j--)
			if((k-1-i)%2 == 0)
				mark[i][j] = val;

	for(int j = 0; j < k; j++)
		for(int i = j; i < k-j; i++)
			if(j%2 == 0)
				mark[i][j] = val;
	for(int j = k-1; j > 0; j--)
		for(int i = j; i >= k-1-j; i--)
			if((k-1-j)%2 == 0)
				mark[i][j] = val;
}

int main(){

	cin >> k;

	if(k%2)
		cout << -1 << endl;
	else{
		for(int i = 0; i < k; i++){
			f(i%2);
			for(int r = 0; r < k; r++){
				for(int c = 0; c < k; c++)
					cout << (mark[r][c]? 'w': 'b') << " ";
				cout << endl;
			}
			if(i < k-1)
				cout << endl;
		}
	}
}


#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=2e5+5;
int top=1,n,k,a[maxn],b[maxn],ans,out[maxn];bool p[maxn],q[maxn];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
	{
		p[a[i]]=1;q[b[i]]=1;
		while(p[top]==1&&q[top]==1)
		{
			out[top]=ans;
			top++;
		}
		if(top==i+1)
			ans++;
	}
	if(ans>=k)
	{
		printf("YES\n");
		for(int i=1;i<=n;i++)
		{
			if(out[i]>=26)
				out[i]=25;
			printf("%c",out[i]+'a');
		}
	}
	else
		printf("NO");
//	fclose(stdin);
//	fclose(stdout);
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=2e5+5;
int h=-1,t=-1,n,k,a[maxn],b[maxn],ans,out[maxn],l;bool p[maxn],q[maxn],g;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
	{
		p[a[i]]=1;q[b[i]]=1;
		if(p[a[i]]==1&&q[a[i]]==1)
			l++;
		if(a[i]!=b[i]&&p[b[i]]==1&&q[b[i]]==1)
			l++;
		out[a[i]]=out[b[i]]=ans;
		if(l==i)
			ans++;
	}
	if(ans>=k)
	{
		printf("YES\n");
		for(int i=1;i<=n;i++)
		{
			if(out[i]>=26)
				out[i]=25;
			printf("%c",out[i]+'a');
		}
	}
	else
		printf("NO");
//	fclose(stdin);
//	fclose(stdout);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

//////////

const int N = 4e5 + 5;

set<int> directed[N], directed2[N];

int par[N], pre[N], mark[N], color[N];
char toposet[N];

stack<int> recur, order;
bool in_stack[N];

int root (int v)
{
    return par[v] < 0 ? v : (par[v] = root(par[v]));
}

void join (int x, int y)
{
    if ((x = root(x)) == (y = root(y)))
        return;
    if (par[y] < par[x])
        swap(x, y);
    par[x] += par[y];
    par[y] = x;
}

void dfs_detect_cycle (int x, int pa, int& cycleNumber)
{
    if (color[x] == 2)
        return;
    if (color[x] == 1)
    {
        ++cycleNumber;
        int cur = pa;
        mark[cur] = cycleNumber;

        while (cur != x)
        {
            cur = pre[cur];
            mark[cur] = cycleNumber;
        }
        return;
    }
    pre[x] = pa;
    color[x] = 1;
    for (int u: directed[x])
        dfs_detect_cycle(u, x, cycleNumber);
    color[x] = 2;
}

void topo (int x)
{
    color[x] = 1;
    for (int u: directed2[x])
        if (!color[u])
            topo(u);
    order.push(x);
}

void Solve()
{
    for (int i = 0; i < N; ++i)
        par[i] = -1;

    int n, k, x, pre;
    cin >> n >> k;
    for (int i = pre = 0; i < n; ++i)
    {
        cin >> x;
        directed[pre].insert(x);
        pre = x;
    }
    for (int i = pre = 0; i < n; ++i)
    {
        cin >> x;
        directed[pre].insert(x);
        pre = x;
    }
    int cycleNumber = n + 5;
    for (int i = 1; i <= n; ++i)
        if (color[i] != 2)
            dfs_detect_cycle(i, 0, cycleNumber);
    for (int i = 1; i <= n; ++i)
        if (mark[i])
            join(mark[i], i);
    for (int i = 1; i <= n; ++i)
        for (int u: directed[i])
            if (root(i) != root(u))
                directed2[root(i)].insert(root(u));
    memset(color, 0, sizeof color);
    for (int i = 1; i <= n; ++i)
        if (!color[root(i)])
            topo(root(i));
    if ((int)order.size() < k)
    {
        cout << "NO";
        return;
    }
    cout << "YES" << endl;
    char curr = 'a';
    while (!order.empty())
    {
        toposet[order.top()] = curr;
        if ((int)order.size() <= k)
            ++curr;
        order.pop();
    }
    for (int i = 1; i <= n; ++i)
        cout << toposet[root(i)];
}

//////////

int main()
{
    ios_base::sync_with_stdio(0);
    Solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

//////////

const int N = 4e5 + 5;

set<int> directed[N], directed2[N];

int par[N], pre[N], mark[N], color[N];
char toposet[N];

stack<int> recur, order;
bool in_stack[N];

int root (int v)
{
    return par[v] < 0 ? v : (par[v] = root(par[v]));
}

void join (int x, int y)
{
    if (x == root(x) || y == root(y))
        return;
    if (par[y] < par[x])
        swap(x, y);
    par[x] += par[y];
    par[y] = x;
}

void dfs_detect_cycle (int x, int pa, int& cycleNumber)
{
    if (color[x] == 2)
        return;
    if (color[x] == 1)
    {
        ++cycleNumber;
        int cur = pa;
        mark[cur] = cycleNumber;

        while (cur != x)
        {
            cur = pre[cur];
            mark[cur] = cycleNumber;
        }
        return;
    }
    pre[x] = pa;
    color[x] = 1;
    for (int u: directed[x])
        dfs_detect_cycle(u, x, cycleNumber);
    color[x] = 2;
}

void topo (int x)
{
    color[x] = 1;
    for (int u: directed2[x])
        if (!color[u])
            topo(u);
    order.push(x);
}

void Solve()
{
    for (int i = 0; i < N; ++i)
        par[i] = -1;

    int n, k, x, pre;
    cin >> n >> k;
    for (int i = pre = 0; i < n; ++i)
    {
        cin >> x;
        directed[pre].insert(x);
    }
    for (int i = pre = 0; i < n; ++i)
    {
        cin >> x;
        directed[pre].insert(x);
    }
    int cycleNumber = n + 5;
    for (int i = 1; i <= n; ++i)
        if (color[i] != 2)
            dfs_detect_cycle(i, 0, cycleNumber);
    for (int i = 1; i <= n; ++i)
        if (mark[i])
            join(mark[i], i);
    for (int i = 1; i <= n; ++i)
        for (int u: directed[i])
            if (root(i) != root(u))
                directed2[root(i)].insert(root(u));
    memset(color, 0, sizeof color);
    int different = 0;
    for (int i = 1; i <= n; ++i)
        if (!color[root(i)])
        {
            ++different;
            topo(root(i));
        }
    if (different < k)
    {
        cout << "NO";
        return;
    }
    cout << "YES" << endl;
    char curr = 'z';
    while (!order.empty())
    {
        toposet[order.top()] = curr;
        if ((int)order.size() <= k)
            --curr;
        order.pop();
    }
    for (int i = 1; i <= n; ++i)
        cout << toposet[root(i)];
}

//////////

int main()
{
    Solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

//////////

const int N = 4e5 + 5;

set<int> directed[N], directed2[N];

int par[N], pre[N], mark[N], color[N];
char toposet[N];

stack<int> recur, order;
bool in_stack[N];

int root (int v)
{
    return par[v] < 0 ? v : (par[v] = root(par[v]));
}

void join (int x, int y)
{
    if ((x = root(x)) == (y = root(y)))
        return;
    if (par[y] < par[x])
        swap(x, y);
    par[x] += par[y];
    par[y] = x;
}

void dfs_detect_cycle (int x, int pa, int& cycleNumber)
{
    if (color[x] == 2)
        return;
    if (color[x] == 1)
    {
        ++cycleNumber;
        int cur = pa;
        mark[cur] = cycleNumber;

        while (cur != x)
        {
            cur = pre[cur];
            mark[cur] = cycleNumber;
        }
        return;
    }
    pre[x] = pa;
    color[x] = 1;
    for (int u: directed[x])
        dfs_detect_cycle(u, x, cycleNumber);
    color[x] = 2;
}

void topo (int x)
{
    color[x] = 1;
    for (int u: directed2[x])
        if (!color[u])
            topo(u);
    order.push(x);
}

void Solve()
{
    for (int i = 0; i < N; ++i)
        par[i] = -1;

    int n, k, x, pre;
    cin >> n >> k;
    for (int i = pre = 0; i < n; ++i)
    {
        cin >> x;
        directed[pre].insert(x);
        pre = x;
    }
    for (int i = pre = 0; i < n; ++i)
    {
        cin >> x;
        directed[pre].insert(x);
        pre = x;
    }
    int cycleNumber = n + 5;
    for (int i = 1; i <= n; ++i)
        if (color[i] != 2)
            dfs_detect_cycle(i, 0, cycleNumber);
    for (int i = 1; i <= n; ++i)
        if (mark[i])
            join(mark[i], i);
    for (int i = 1; i <= n; ++i)
        for (int u: directed[i])
            if (root(i) != root(u))
                directed2[root(i)].insert(root(u));
    memset(color, 0, sizeof color);
    for (int i = 1; i <= n; ++i)
        if (!color[root(i)])
            topo(root(i));
    if ((int)order.size() < k)
    {
        cout << "NO";
        return;
    }
    cout << "YES" << endl;
    char curr = 'a';
    while (!order.empty())
    {
        toposet[order.top()] = curr;
        if ((int)order.size() <= k)
            ++curr;
        order.pop();
    }
    for (int i = 1; i <= n; ++i)
        cout << toposet[root(i)];
}

//////////

int main()
{
    Solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

int n, k, p[N], q[N], chp[N], chq[N], gr[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
    {
        cin >> p[i];
        chp[p[i]] = i;
    }
    for (int i = 1; i <= n; ++i)
    {
        cin >> q[i];
        chq[q[i]] = i;
    }
    int p_tr = n, q_tr = n, g_tr = 0, exceed = 0, alt;
    while (p_tr)
    {
        if (gr[p[p_tr]])
            if (--p_tr <= 0)
                break;
        int min_p = n, min_q = chq[p[p_tr]];
        do
        {
            alt = 0;
            while (q_tr && min_q <= q_tr)
            {
                min_p = min(min_p, chp[q[q_tr]]);
                gr[q[q_tr--]] = g_tr;
                alt = 1;
            }
            while (p_tr && min_p <= p_tr)
            {
                min_q = min(min_q, chq[p[p_tr]]);
                gr[p[p_tr--]] = g_tr;
                alt = 1;
            }
        } while (alt);
        if (g_tr == 25)
        {
            g_tr = 25;
            exceed = 1;
        }
        else
            ++g_tr;
    }
    if (g_tr + exceed >= k)
    {
        cout << "YES" << endl;
        for (int i = 1; i <= n; ++i)
            cout << char(122 - gr[i]);
    }
    else
        cout << "NO" << endl;
    return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
stack<int> S;
vector<int> rev[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to])
			Tarjan(e[i].to),
			ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	if(sum<k) puts("NO"),exit(0);
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) putchar(color[i]+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN],dep[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to]) Tarjan(e[i].to),ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,sum) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,sum) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(!(--du[quq])) Q.push(quq);
	}
	int Max=0;
	rep(i,1,sum) for(auto quq:G[mat[i]]) ylmax(dep[quq],dep[mat[i]]+1);
	rep(i,1,sum) ylmax(Max,++dep[i]);
	if(Max<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,1,n) putchar(min(dep[color[i]],k)+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to])
			Tarjan(e[i].to),
			ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	if(sum<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,n) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,n) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(!(--du[quq])) Q.push(quq);
	}
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) putchar(mat[color[i]]+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to])
			Tarjan(e[i].to),
			ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	if(sum<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,n) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,n) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(quq!=u && !(--du[quq])) Q.push(quq);
	}
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) putchar(mat[color[i]]+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
stack<int> S;
vector<int> rev[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to])
			Tarjan(e[i].to),
			ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	if(sum<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) putchar(color[i]+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN],dep[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to]) Tarjan(e[i].to),ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,sum) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,sum) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(!(--du[quq])) Q.push(quq);
	}
	int Max=0;
	rep(i,1,sum) dep[i]=1;
	rep(i,1,sum) for(auto quq:G[mat[i]]) if(quq!=i) ylmax(dep[quq],dep[mat[i]]+1);
	rep(i,1,sum) ylmax(Max,dep[i]);
	if(Max<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,1,n) putchar(min(dep[color[i]],k)+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to])
			Tarjan(e[i].to),
			ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	if(sum<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,n) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,n) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(quq!=i && !(--du[quq])) Q.push(quq);
	}
	rep(i,1,n) putchar(mat[color[i]]+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN],dep[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to]) Tarjan(e[i].to),ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) if(color[i]!=color[e[j].to]) G[color[i]].pb(color[e[j].to]);
	rep(i,1,sum) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,sum) for(auto quq:G[i]) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	rep(i,1,sum) dep[i]=1;
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		for(auto quq:G[u]) {
			ylmax(dep[quq],dep[u]+1);
			if(!(--du[quq])) Q.push(quq);
		}
	}
	int Max=0;
	rep(i,1,sum) ylmax(Max,dep[i]);
	if(Max<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,1,n) putchar(min(dep[color[i]],k)+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN],dep[MAXN],fa[MAXN],Max[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to]) Tarjan(e[i].to),ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
inl int find(int u){return fa[u]==u?u:fa[u]=find(fa[u]);}
inl void Merge(int u,int v){u=find(u),v=find(v);if(u!=v) fa[u]=v;}
int main(){
//	freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,sum) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,sum) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	rep(i,1,sum) fa[i]=i;
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(!(--du[quq])) Q.push(quq);
	}
	int all=0;
	rep(i,1,sum) dep[i]=1;
	rep(i,1,sum) for(auto quq:G[mat[i]]) if(quq!=i) ylmax(dep[quq],dep[mat[i]]+1),Merge(i,quq);
	rep(i,1,sum) ylmax(Max[find(i)],dep[i]);
	rep(i,1,sum) all+=Max[i];
	if(all<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,1,n) putchar(min(dep[color[i]],k)+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN],dep[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to]) Tarjan(e[i].to),ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	puts("YES");
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,sum) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,sum) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(!(--du[quq])) Q.push(quq);
	}
	int Max=0;
	rep(i,1,sum) for(auto quq:G[mat[i]]) ylmax(dep[quq],dep[mat[i]]+1);
	rep(i,1,sum) ylmax(Max,++dep[i]);
	if(Max<k) puts("NO"),exit(0);
	rep(i,1,n) putchar(min(dep[color[i]],k)+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to])
			Tarjan(e[i].to),
			ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
//	freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	if(sum<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,sum) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,sum) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(!(--du[quq])) Q.push(quq);
	}
	rep(i,1,n) putchar(mat[color[i]]+'a'-1),assert(mat[color[i]]);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to]) Tarjan(e[i].to),ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	if(sum<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,sum) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,sum) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(!(--du[quq])) Q.push(quq);
	}
	rep(i,1,k) assert(mat[i]);
	rep(i,1,n) putchar(mat[color[i]]+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to])
			Tarjan(e[i].to),
			ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	if(sum<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,n) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,n) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(!(--du[quq])) Q.push(quq);
	}
	rep(i,1,n) putchar(mat[color[i]]+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to])
			Tarjan(e[i].to),
			ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
int main(){
//	freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	if(sum<k) puts("NO"),exit(0);
	puts("YES");rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) G[color[i]].pb(color[e[j].to]);
	rep(i,1,n) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,n) for(auto quq:G[i]) if(quq!=i) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	while(!Q.empty()){
		int u=Q.front();mat[u]=++tot;Q.pop();
		for(auto quq:G[u]) if(quq!=u && !(--du[quq])) Q.push(quq);
	}

	rep(i,1,n) putchar(mat[color[i]]+'a'-1);
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 2e5+10;
int n,k,dfs_time,cnt,sum,p[MAXN],q[MAXN],head[MAXN],dfn[MAXN],low[MAXN],color[MAXN];
int tot,ans[MAXN],du[MAXN],mat[MAXN],dep[MAXN],fa[MAXN],Max[MAXN];
stack<int> S;
queue<int> Q;
vector<int> rev[MAXN],G[MAXN];
struct Edge{int to,next;}e[MAXN<<1];
template<class T>inl void ylmin(T &a,T b){a=a<b?a:b;}
template<class T>inl void ylmax(T &a,T b){a=a>b?a:b;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
inl void Tarjan(int now){
	dfn[now]=low[now]=++dfs_time;
	S.push(now);
	travel(i,now){
		if(!dfn[e[i].to]) Tarjan(e[i].to),ylmin(low[now],low[e[i].to]);
		else if(!color[e[i].to]) ylmin(low[now],dfn[e[i].to]);
	}
	if(dfn[now]==low[now]){
		color[now]=++sum;rev[sum].pb(now);
		while(S.top()!=now){
			color[S.top()]=sum;
			rev[sum].pb(S.top());
			S.pop();
		}S.pop();
	}
}
inl void add(int u,int v){e[++cnt]={v,head[u]};head[u]=cnt;}
inl int find(int u){return fa[u]==u?u:fa[u]=find(fa[u]);}
inl void Merge(int u,int v){u=find(u),v=find(v);if(u!=v) fa[u]=v;}
int main(){
	//freopen("in.txt","r",stdin);
	read(n),read(k);
	rep(i,1,n) read(p[i]);
	rep(i,1,n) read(q[i]);
	rep(i,1,n-1) add(p[i],p[i+1]);
	rep(i,1,n-1) add(q[i],q[i+1]);
	rep(i,1,n) if(!dfn[i]) Tarjan(i);
	rep(i,k+1,sum) for(auto quq:rev[i]) color[quq]=k;
	rep(i,1,n) travel(j,i) if(color[i]!=color[e[j].to]) G[color[i]].pb(color[e[j].to]);
	rep(i,1,sum) sort(all(G[i])),G[i].erase(unique(all(G[i])),G[i].end());
	rep(i,1,sum) for(auto quq:G[i]) du[quq]++;
	rep(i,1,sum) if(!du[i]) Q.push(i);
	rep(i,1,sum) fa[i]=i,dep[i]=1;
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		for(auto quq:G[u]) {
			ylmax(dep[quq],dep[u]+1);
			Merge(u,quq);
			if(!(--du[quq])) Q.push(quq);
		}
	}
	int all=0;
	rep(i,1,sum) ylmax(Max[find(i)],dep[i]);
	rep(i,1,sum) all+=Max[i];
	if(all<k) puts("NO"),exit(0);
	puts("YES");
	rep(i,1,n) putchar(min(dep[color[i]],k)+'a'-1);
	return 0;
}


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

vector<vector<int>> x; //normal
vector<vector<int>> y; //reverse
vector<int> order;
bool vis[200005]={};
int com[200005]={};
int temp[200005]={};

void dfs1(int now){
	vis[now]=1;
	for (int v:x[now]){
		if (!vis[v])dfs1(v);
	}
	order.push_back(now);
}

void dfs2(int now,int count){
	vis[now]=1;
	for (int v:y[now]){
		if (!vis[v])dfs2(v,count);
	}
	com[now]=count;
}

int main(){
	int n,q;
	cin>>n>>q;
	x.resize(n);
	y.resize(n);
	for (int i=0;i<2;i++){
		for (int j=0;j<n;j++)cin>>temp[j],temp[j]--;
		for (int j=0;j<n-1;j++){
		x[temp[j]].push_back(temp[j+1]);
		y[temp[j+1]].push_back(temp[j]);
		}
	}

	for (int i=0;i<n;i++){
		if (!vis[i])dfs1(i);
	//cout<<"alsfjasklf";
	}
	for (int i=0;i<n;i++)vis[i]=0;
	int count=1;
	for (int i=0;i<n;i++){
		int z=order[n-1-i];
		if (!vis[z]){
		dfs2(z,count);
		count++;
		}
	}
	if (q>count-1 || q>=26){
	cout<<"NO"<<endl;
	return 0;
	}
	string s;
	s.resize(n);
	for (int i=0;i<n;i++){
		s[i]='a'+com[i]-1;
	}
	cout<<"YES\n";
	cout<<s<<endl;
//	cout<<com[0]<<endl;
}


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

vector<vector<int>> x; //normal
vector<vector<int>> y; //reverse
vector<int> order;
bool vis[200005]={};
int com[200005]={};
int temp[200005]={};

void dfs1(int now){
	vis[now]=1;
	for (int v:x[now]){
		if (!vis[v])dfs1(v);
	}
	order.push_back(now);
}

void dfs2(int now,int count){
	vis[now]=1;
	for (int v:y[now]){
		if (!vis[v])dfs2(v,count);
	}
	com[now]=count;
}

int main(){
	int n,q;
	cin>>n>>q;
	x.resize(n);
	y.resize(n);
	for (int i=0;i<2;i++){
		for (int j=0;j<n;j++)cin>>temp[j],temp[j]--;
		for (int j=0;j<n-1;j++){
		x[temp[j]].push_back(temp[j+1]);
		y[temp[j+1]].push_back(temp[j]);
		}
	}

	for (int i=0;i<n;i++){
		if (!vis[i])dfs1(i);
	//cout<<"alsfjasklf";
	}
	for (int i=0;i<n;i++)vis[i]=0;
	int count=1;
	for (int i=0;i<n;i++){
		int z=order[n-1-i];
		if (!vis[z]){
		dfs2(z,count);
		if (count<q)count++;
		}
	}
	if (q>count-1 || q>=26){
	cout<<"NO"<<endl;
	return 0;
	}
	string s;
	s.resize(n);
	for (int i=0;i<n;i++){
		s[i]='a'+com[i]-1;
	}
	cout<<"YES\n";
	cout<<s<<endl;
//	cout<<com[0]<<endl;
}


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

vector<vector<int>> x; //normal
vector<vector<int>> y; //reverse
vector<int> order;
bool vis[200005]={};
int com[200005]={};
int temp[200005]={};

void dfs1(int now){
	vis[now]=1;
	for (int v:x[now]){
		if (!vis[v])dfs1(v);
	}
	order.push_back(now);
}

void dfs2(int now,int count){
	vis[now]=1;
	for (int v:y[now]){
		if (!vis[v])dfs2(v,count);
	}
	com[now]=count;
}

int main(){
	int n,q;
	cin>>n>>q;
	x.resize(n);
	y.resize(n);
	for (int i=0;i<2;i++){
		for (int j=0;j<n;j++)cin>>temp[j],temp[j]--;
		for (int j=0;j<n-1;j++){
		x[temp[j]].push_back(temp[j+1]);
		y[temp[j+1]].push_back(temp[j]);
		}
	}

	for (int i=0;i<n;i++){
		if (!vis[i])dfs1(i);
	//cout<<"alsfjasklf";
	}
	for (int i=0;i<n;i++)vis[i]=0;
	int count=1;
	for (int i=0;i<n;i++){
		int z=order[n-1-i];
		if (!vis[z]){
		dfs2(z,count);
		if (count<=q)count++;
		}
	}
	if (q>count-1){
	cout<<"NO"<<endl;
	return 0;
	}
	string s;
	s.resize(n);
	for (int i=0;i<n;i++){
		char t='a'+com[i]-1;
		if (t>'z')t='z';
		s[i]=t;
	}
	cout<<"YES\n";
	cout<<s<<endl;
//	cout<<com[0]<<endl;
}


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

vector<vector<int>> x; //normal
vector<vector<int>> y; //reverse
vector<int> order;
bool vis[200005]={};
int com[200005]={};
int temp[200005]={};

void dfs1(int now){
	vis[now]=1;
	for (int v:x[now]){
		if (!vis[v])dfs1(v);
	}
	order.push_back(now);
}

void dfs2(int now,int count){
	vis[now]=1;
	for (int v:y[now]){
		if (!vis[v])dfs2(v,count);
	}
	com[now]=count;
}

int main(){
	int n,q;
	cin>>n>>q;
	x.resize(n);
	y.resize(n);
	for (int i=0;i<2;i++){
		for (int j=0;j<n;j++)cin>>temp[j],temp[j]--;
		for (int j=0;j<n-1;j++){
		x[temp[j]].push_back(temp[j+1]);
		y[temp[j+1]].push_back(temp[j]);
		}
	}

	for (int i=0;i<n;i++){
		if (!vis[i])dfs1(i);
	//cout<<"alsfjasklf";
	}
	for (int i=0;i<n;i++)vis[i]=0;
	int count=1;
	for (int i=0;i<n;i++){
		int z=order[n-1-i];
		if (!vis[z]){
		dfs2(z,count);
		if (count<=q)count++;
		}
	}
	if (q>count-1 || q>=26){
	cout<<"NO"<<endl;
	return 0;
	}
	string s;
	s.resize(n);
	for (int i=0;i<n;i++){
		s[i]='a'+com[i]-1;
	}
	cout<<"YES\n";
	cout<<s<<endl;
//	cout<<com[0]<<endl;
}


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

vector<vector<int>> x; //normal
vector<vector<int>> y; //reverse
vector<int> order;
bool vis[200005]={};
int com[200005]={};
int temp[200005]={};

void dfs1(int now){
	vis[now]=1;
	for (int v:x[now]){
		if (!vis[v])dfs1(v);
	}
	order.push_back(now);
}

void dfs2(int now,int count){
	vis[now]=1;
	for (int v:y[now]){
		if (!vis[v])dfs2(v,count);
	}
	com[now]=count;
}

int main(){
	int n,q;
	cin>>n>>q;
	x.resize(n);
	y.resize(n);
	for (int i=0;i<2;i++){
		for (int j=0;j<n;j++)cin>>temp[j],temp[j]--;
		for (int j=0;j<n-1;j++){
		x[temp[j]].push_back(temp[j+1]);
		y[temp[j+1]].push_back(temp[j]);
		}
	}

	for (int i=0;i<n;i++){
		if (!vis[i])dfs1(i);
	//cout<<"alsfjasklf";
	}
	for (int i=0;i<n;i++)vis[i]=0;
	int count=1;
	for (int i=0;i<n;i++){
		int z=order[n-1-i];
		if (!vis[z]){
		dfs2(z,count);
		if (count<=q)count++;
		}
	}
	if (q>count-1){
	cout<<"NO"<<endl;
	return 0;
	}
	string s;
	s.resize(n);
	for (int i=0;i<n;i++){
		s[i]='a'+com[i]-1;
	}
	cout<<"YES\n";
	cout<<s<<endl;
//	cout<<com[0]<<endl;
}


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

vector<vector<int>> x; //normal
vector<vector<int>> y; //reverse
vector<int> order;
bool vis[200005]={};
int com[200005]={};
int temp[200005]={};

void dfs1(int now){
	vis[now]=1;
	for (int v:x[now]){
		if (!vis[v])dfs1(v);
	}
	order.push_back(now);
}

void dfs2(int now,int count){
	vis[now]=1;
	for (int v:y[now]){
		if (!vis[v])dfs2(v,count);
	}
	com[now]=count;
}

int main(){
	int n,q;
	cin>>n>>q;
	x.resize(n);
	y.resize(n);
	for (int i=0;i<2;i++){
		for (int j=0;j<n;j++)cin>>temp[j],temp[j]--;
		for (int j=0;j<n-1;j++){
		x[temp[j]].push_back(temp[j+1]);
		y[temp[j+1]].push_back(temp[j]);
		}
	}

	for (int i=0;i<n;i++){
		if (!vis[i])dfs1(i);
	//cout<<"alsfjasklf";
	}
	for (int i=0;i<n;i++)vis[i]=0;
	int count=1;
	for (int i=0;i<n;i++){
		int z=order[n-1-i];
		if (!vis[z]){
		dfs2(z,count);
		count++;
		}
	}
	if (q>count){
	cout<<"NO"<<endl;
	return 0;
	}
	string s;
	s.resize(n);
	for (int i=0;i<n;i++){
		s[i]='a'+com[i];
	}
	cout<<"YES\n";
	cout<<s<<endl;
//	cout<<com[0]<<endl;
}


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

vector<vector<int>> x; //normal
vector<vector<int>> y; //reverse
vector<int> order;
bool vis[200005]={};
int com[200005]={};
int temp[200005]={};

void dfs1(int now){
	vis[now]=1;
	for (int v:x[now]){
		if (!vis[v])dfs1(v);
	}
	order.push_back(now);
}

void dfs2(int now,int count){
	vis[now]=1;
	for (int v:y[now]){
		if (!vis[v])dfs2(v,count);
	}
	com[now]=count;
}

int main(){
	int n,q;
	cin>>n>>q;
	x.resize(n);
	y.resize(n);
	for (int i=0;i<2;i++){
		for (int j=0;j<n;j++)cin>>temp[j],temp[j]--;
		for (int j=0;j<n-1;j++){
		x[temp[j]].push_back(temp[j+1]);
		y[temp[j+1]].push_back(temp[j]);
		}
	}

	for (int i=0;i<n;i++){
		if (!vis[i])dfs1(i);
	//cout<<"alsfjasklf";
	}
	for (int i=0;i<n;i++)vis[i]=0;
	int count=1;
	for (int i=0;i<n;i++){
		int z=order[n-1-i];
		if (!vis[z]){
		dfs2(z,count);
		count++;
		}
	}
	if (q>count-1 || q>=26){
	cout<<"NO"<<endl;
	return 0;
	}
	string s;
	s.resize(n);
	for (int i=0;i<n;i++){
		s[i]='a'+com[i];
	}
	cout<<"YES\n";
	cout<<s<<endl;
//	cout<<com[0]<<endl;
}


#include <bits/stdc++.h>

using namespace std;
int n,k;
int ans=0;
set<int>s1;
set<int>s2;
set<int>s;
int a[300000];
int b[300000];
int c[300000];
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int j=1;j<=n;j++)
cin>>b[j];
for(int i=1;i<=n;i++)
{
    c[a[i]]=ans;
    c[b[i]]=ans;
    if(a[i]!=b[i]){
    if(!s2.count(a[i]))
    s1.insert(a[i]);
    else
    s2.erase(s2.find(a[i]));
    if(!s1.count(b[i]))
    s2.insert(b[i]);
    else
    s1.erase(s1.find(b[i]));}
    if(s1.empty()&&s2.empty())
    ans++;
}
if(ans>=k)
cout<<"YES"<<endl;
else
{cout<<"NO";
return 0;}
char ch[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
for(int i=1;i<=n;i++)
{
cout<<ch[min(c[i],25)];
}

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,k;
int ans=0;
set<int>s1;
set<int>s2;
set<int>s;
int a[300000];
int b[300000];
char c[300000];
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int j=1;j<=n;j++)
cin>>b[j];
for(int i=1;i<=n;i++)
{
    c[a[i]]=ans;
    c[b[i]]=ans;
    if(a[i]!=b[i]){
    if(!s2.count(a[i]))
    s1.insert(a[i]);
    else
    s2.erase(s2.find(a[i]));
    if(!s1.count(b[i]))
    s2.insert(b[i]);
    else
    s1.erase(s1.find(b[i]));}
    if(s1.empty()&&s2.empty())
    ans++;
}
if(ans>=k)
cout<<"YES"<<endl;
else
{cout<<"NO";
return 0;}
for(int i=1;i<=n;i++)
{
    if(c[i]<='z')
    cout<<(char)('a'=c[i]);
    else
    cout<<'z';
}

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,k;
int ans=0;
set<int>s1;
set<int>s2;
set<int>s;
int a[300000];
int b[300000];
char c[300000];
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int j=1;j<=n;j++)
cin>>b[j];
for(int i=1;i<=n;i++)
{
    c[a[i]]=ans;
    c[b[i]]=ans;
    if(a[i]!=b[i]){
    if(!s2.count(a[i]))
    s1.insert(a[i]);
    else
    s2.erase(s2.find(a[i]));
    if(!s1.count(b[i]))
    s2.insert(b[i]);
    else
    s1.erase(s1.find(b[i]));}
    if(s1.empty()&&s2.empty())
    ans++;
}
if(ans>=k)
cout<<"YES"<<endl;
else
{cout<<"NO";
return 0;}
for(int i=1;i<=n;i++)
cout<<(char)min(25+'a',c[i]+'a');

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,k;
int ans=0;
set<int>s1;
set<int>s2;
set<int>s;
int a[300000];
int b[300000];
char c[300000];
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int j=1;j<=n;j++)
cin>>b[j];
for(int i=1;i<=n;i++)
{
    c[a[i]]=ans;
    c[b[i]]=ans;
    if(a[i]!=b[i]){
    if(!s2.count(a[i]))
    s1.insert(a[i]);
    else
    s2.erase(s2.find(a[i]));
    if(!s1.count(b[i]))
    s2.insert(b[i]);
    else
    s1.erase(s1.find(b[i]));}
    if(s1.empty()&&s2.empty())
    ans++;
}
if(ans>=k)
cout<<"YES"<<endl;
else
{cout<<"NO";
return 0;}
for(int i=1;i<=n;i++)
{
    if(c[i]<26)
    cout<<(char)('a'+c[i]);
    else
    cout<<'z';
}

    return 0;


#include <bits/stdc++.h>

using namespace std;
int n,k;
int ans=0;
set<int>s1;
set<int>s2;
set<int>s;
int a[300000];
int b[300000];
char c[300000];
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int j=1;j<=n;j++)
cin>>b[j];
for(int i=1;i<=n;i++)
{
    c[a[i]]=ans;
    c[b[i]]=ans;
    if(a[i]!=b[i]){
    if(!s2.count(a[i]))
    s1.insert(a[i]);
    else
    s2.erase(s2.find(a[i]));
    if(!s1.count(b[i]))
    s2.insert(b[i]);
    else
    s1.erase(s1.find(b[i]));}
    if(s1.empty()&&s2.empty())
    ans++;
}
if(ans>=k)
cout<<"YES"<<endl;
else
{cout<<"NO";
return 0;}
for(int i=1;i<=n;i++)
{
    if(c[i]<26)
    cout<<(char)('a'+c[i]);
    else
    cout<<'z';
}

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,k;
int ans=0;
set<int>s1;
set<int>s2;
set<int>s;
int a[300000];
int b[300000];
char c[300000];
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int j=1;j<=n;j++)
cin>>b[j];
for(int i=1;i<=n;i++)
{
    c[a[i]]=ans;
    c[b[i]]=ans;
    if(a[i]!=b[i]){
    if(!s2.count(a[i]))
    s1.insert(a[i]);
    else
    s2.erase(s2.find(a[i]));
    if(!s1.count(b[i]))
    s2.insert(b[i]);
    else
    s1.erase(s1.find(b[i]));}
    if(s1.empty()&&s2.empty())
    ans++;
}
if(ans>=k)
cout<<"YES"<<endl;
else
{cout<<"NO";
return 0;}
for(int i=1;i<=n;i++)
{
    if(c[i]<26)
    cout<<(char)('a'=c[i]);
    else
    cout<<'z';
}

    return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e9;
const ll N=2e5+100;

vector<int> v[N],tra[N]; // v is original tra is it's transpose
bool visited[N];
vector<int> order;
vector<int> component;
int vertex[N]; // vertex[i] will store the representative element for  scc to which i belong
void dfs(int node)
{
	visited[node]=1;
	for(auto &i:v[node])
	{
		if(visited[i]==0)
		{
			dfs(i);
		}
	}
	order.pb(node);
}

void dfs2(int node)
{
	visited[node]=1;
	for(auto &i:tra[node])
	{
		if(visited[i]==0)
		{
			dfs2(i);
		}
	}
	component.pb(node);
}

int find_scc(int n)
{
	memset(visited,0,sizeof(visited));
    for(int i=0;i<n;i++)
    {
    	if(visited[i]==0)
    	{
    		dfs(i);
    	}
    }
    reverse(all(order));
    int cnt=0;
    memset(visited,0,sizeof(visited));
    for(auto &i:order)
    {
    	if(visited[i]==0)
    	{
    		dfs2(i);
    		for(auto &j:component) vertex[j]=cnt;
    		cnt++;
    		component.clear();
    	}
    }
    return cnt;

}

set< int > v1[100];
vector<int> topo;
bool small_visited[100];
void dfs3(int node)
{
	small_visited[node]=1;
	for(auto &i:v1[node])
	{
		if(small_visited[i]==0)
		{
			dfs3(i);
		}
	}
	topo.pb(node);
}

int main()
{
	boost;
	int n,k;
	cin>>n>>k;
	int prev;
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	int scc=find_scc(n);
	//check(scc);
	if(k>scc)
	{
		cout<<"NO";
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(auto &j:v[i])
		{
			v1[vertex[i]].insert(vertex[j]);
		}
	}
	for(int i=0;i<scc;i++)
	{
		if(small_visited[i]==0) dfs3(i);
	}

	char ans[scc+10];
	int now=0;
	reverse(all(topo));
	for(auto &i:topo)
	{
		//check(i);
		ans[i]='a'+now;
		now=min(now+1,k-1);
	}
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++)
	{
		cout<<ans[vertex[i]];
	}

	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e9;
const ll N=2e5+10;

vector<int> v[N],tra[N]; // v is original tra is it's transpose
bool visited[N];
vector<int> order;
vector<int> component;
int vectex[N]; // vertex[i] will store the representative element for  scc to which i belong
void dfs(int node)
{
	visited[node]=1;
	for(auto &i:v[node])
	{
		if(visited[i]==0)
		{
			dfs(i);
		}
	}
	order.pb(node);
}

void dfs2(int node)
{
	visited[node]=1;
	for(auto &i:tra[node])
	{
		if(visited[i]==0)
		{
			dfs2(i);
		}
	}
	component.pb(node);
}

int find_scc(int n)
{
	memset(visited,0,sizeof(visited));
    for(int i=0;i<n;i++)
    {
    	if(visited[i]==0)
    	{
    		dfs(i);
    	}
    }
    reverse(all(order));
    int cnt=0;
    memset(visited,0,sizeof(visited));
    for(auto &i:order)
    {
    	if(visited[i]==0)
    	{
    		dfs2(i);
    		for(auto &j:component) vectex[j]=cnt;
    		cnt++;
    		component.clear();
    	}
    }
    return cnt;

}

std::vector< int > v1[30];
vector<int> topo;
bool small_visited[30];
void dfs3(int node)
{
	small_visited[node]=1;
	for(auto &i:v1[node])
	{
		if(small_visited[i]==0)
		{
			dfs3(i);
		}
	}
	topo.pb(node);
}

int main()
{
	boost;
	int n,k;
	cin>>n>>k;
	int prev;
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	int scc=find_scc(n);
	//check(scc);
	if(k>scc)
	{
		cout<<"NO";
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(auto &j:v[i])
		{
			v1[vectex[i]].pb(vectex[j]);
		}
	}
	dfs3(0);
	char ans[scc];
	int now=0;
	reverse(all(topo));
	for(auto &i:topo)
	{
		//check(i);
		ans[i]='a'+now;
		now=min(now+1,k-1);
	}
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++)
	{
		cout<<ans[vectex[i]];
	}

	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e9;
const ll N=2e5+10;

vector<int> v[N],tra[N]; // v is original tra is it's transpose
bool visited[N];
vector<int> order;
vector<int> component;
int vectex[N]; // vertex[i] will store the representative element for  scc to which i belong
void dfs(int node)
{
	visited[node]=1;
	for(auto &i:v[node])
	{
		if(visited[i]==0)
		{
			dfs(i);
		}
	}
	order.pb(node);
}

void dfs2(int node)
{
	visited[node]=1;
	for(auto &i:tra[node])
	{
		if(visited[i]==0)
		{
			dfs2(i);
		}
	}
	component.pb(node);
}

int find_scc(int n)
{
	memset(visited,0,sizeof(visited));
    for(int i=0;i<n;i++)
    {
    	if(visited[i]==0)
    	{
    		dfs(i);
    	}
    }
    reverse(all(order));
    int cnt=0;
    memset(visited,0,sizeof(visited));
    for(auto &i:order)
    {
    	if(visited[i]==0)
    	{
    		dfs2(i);
    		for(auto &j:component) vectex[j]=cnt;
    		cnt++;
    		component.clear();
    	}
    }
    return cnt;

}

set< int > v1[30];
vector<int> topo;
bool small_visited[30];
void dfs3(int node)
{
	small_visited[node]=1;
	for(auto &i:v1[node])
	{
		if(small_visited[i]==0)
		{
			dfs3(i);
		}
	}
	topo.pb(node);
}

int main()
{
	boost;
	int n,k;
	cin>>n>>k;
	int prev;
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	int scc=find_scc(n);
	//check(scc);
	if(k>scc)
	{
		cout<<"NO";
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(auto &j:v[i])
		{
			v1[vectex[i]].insert(vectex[j]);
		}
	}
	for(int i=0;i<scc;i++)
	{
		if(small_visited[i]==0) dfs3(i);
	}

	char ans[scc];
	int now=0;
	reverse(all(topo));
	for(auto &i:topo)
	{
		//check(i);
		ans[i]='a'+now;
		now=min(now+1,k-1);
	}
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++)
	{
		cout<<ans[vectex[i]];
	}

	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e9;
const ll N=2e5+10;

vector<int> v[N],tra[N]; // v is original tra is it's transpose
bool visited[N];
vector<int> order;
vector<int> component;
int vectex[N]; // vertex[i] will store the representative element for  scc to which i belong
void dfs(int node)
{
	visited[node]=1;
	for(auto &i:v[node])
	{
		if(visited[i]==0)
		{
			dfs(i);
		}
	}
	order.pb(node);
}

void dfs2(int node)
{
	visited[node]=1;
	for(auto &i:tra[node])
	{
		if(visited[i]==0)
		{
			dfs2(i);
		}
	}
	component.pb(node);
}

int find_scc(int n)
{
	memset(visited,0,sizeof(visited));
    for(int i=0;i<n;i++)
    {
    	if(visited[i]==0)
    	{
    		dfs(i);
    	}
    }
    reverse(all(order));
    int cnt=0;
    memset(visited,0,sizeof(visited));
    for(auto &i:order)
    {
    	if(visited[i]==0)
    	{
    		dfs2(i);
    		for(auto &j:component) vectex[j]=cnt;
    		cnt++;
    		component.clear();
    	}
    }
    return cnt;

}

set< int > v1[30];
vector<int> topo;
bool small_visited[30];
void dfs3(int node)
{
	small_visited[node]=1;
	for(auto &i:v1[node])
	{
		if(small_visited[i]==0)
		{
			dfs3(i);
		}
	}
	topo.pb(node);
}

int main()
{
	boost;
	int n,k;
	cin>>n>>k;
	int prev;
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	int scc=find_scc(n);
	//check(scc);
	if(k>scc)
	{
		cout<<"NO";
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(auto &j:v[i])
		{
			v1[vectex[i]].insert(vectex[j]);
		}
	}
	dfs3(0);
	char ans[scc];
	int now=0;
	reverse(all(topo));
	for(auto &i:topo)
	{
		//check(i);
		ans[i]='a'+now;
		now=min(now+1,k-1);
	}
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++)
	{
		cout<<ans[vectex[i]];
	}

	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e9;
const ll N=2e5+100;

vector<int> v[N],tra[N]; // v is original tra is it's transpose
bool visited[N];
vector<int> order;
vector<int> component;
int vertex[N]; // vertex[i] will store the representative element for  scc to which i belong
void dfs(int node)
{
	visited[node]=1;
	for(auto &i:v[node])
	{
		if(visited[i]==0)
		{
			dfs(i);
		}
	}
	order.pb(node);
}

void dfs2(int node)
{
	visited[node]=1;
	for(auto &i:tra[node])
	{
		if(visited[i]==0)
		{
			dfs2(i);
		}
	}
	component.pb(node);
}

int find_scc(int n)
{
	memset(visited,0,sizeof(visited));
    for(int i=0;i<n;i++)
    {
    	if(visited[i]==0)
    	{
    		dfs(i);
    	}
    }
    reverse(all(order));
    int cnt=0;
    memset(visited,0,sizeof(visited));
    for(auto &i:order)
    {
    	if(visited[i]==0)
    	{
    		dfs2(i);
    		for(auto &j:component) vertex[j]=cnt;
    		cnt++;
    		component.clear();
    	}
    }
    return cnt;

}

set< int > v1[N];
vector<int> topo;
bool small_visited[N];
void dfs3(int node)
{
	small_visited[node]=1;
	for(auto &i:v1[node])
	{
		if(small_visited[i]==0)
		{
			dfs3(i);
		}
	}
	topo.pb(node);
}

int main()
{
	boost;
	int n,k;
	cin>>n>>k;
	int prev;
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	int scc=find_scc(n);
	//check(scc);
	if(k>scc)
	{
		cout<<"NO";
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(auto &j:v[i])
		{
			v1[vertex[i]].insert(vertex[j]);
		}
	}
	for(int i=0;i<scc;i++)
	{
		if(small_visited[i]==0) dfs3(i);
	}

	char ans[scc+10];
	int now=0;
	reverse(all(topo));
	for(auto &i:topo)
	{
		//check(i);
		ans[i]='a'+now;
		now=min(now+1,k-1);
	}
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++)
	{
		cout<<ans[vertex[i]];
	}

	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e9;
const ll N=2e5+10;

vector<int> v[N],tra[N]; // v is original tra is it's transpose
bool visited[N];
vector<int> order;
vector<int> component;
int vectex[N]; // vertex[i] will store the representative element for  scc to which i belong
void dfs(int node)
{
	visited[node]=1;
	for(auto &i:v[node])
	{
		if(visited[i]==0)
		{
			dfs(i);
		}
	}
	order.pb(node);
}

void dfs2(int node)
{
	visited[node]=1;
	for(auto &i:tra[node])
	{
		if(visited[i]==0)
		{
			dfs2(i);
		}
	}
	component.pb(node);
}

int find_scc(int n)
{
	memset(visited,0,sizeof(visited));
    for(int i=0;i<n;i++)
    {
    	if(visited[i]==0)
    	{
    		dfs(i);
    	}
    }
    reverse(all(order));
    int cnt=0;
    memset(visited,0,sizeof(visited));
    for(auto &i:order)
    {
    	if(visited[i]==0)
    	{
    		dfs2(i);
    		for(auto &j:component) vectex[j]=cnt;
    		cnt++;
    		component.clear();
    	}
    }
    return cnt;

}

set< int > v1[30];
vector<int> topo;
bool small_visited[30];
void dfs3(int node)
{
	small_visited[node]=1;
	for(auto &i:v1[node])
	{
		if(small_visited[i]==0)
		{
			dfs3(i);
		}
	}
	topo.pb(node);
}

int main()
{
	boost;
	int n,k;
	cin>>n>>k;
	int prev;
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	cin>>prev;
	prev--;
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		x--;
		v[prev].pb(x);
		tra[x].pb(prev);
		prev=x;
	}
	int scc=find_scc(n);
	//check(scc);
	if(k<scc)
	{
		cout<<"NO";
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(auto &j:v[i])
		{
			v1[vectex[i]].insert(vectex[j]);
		}
	}
	dfs3(0);
	char ans[scc];
	int now=0;
	reverse(all(topo));
	for(auto &i:topo)
	{
		//check(i);
		ans[i]='a'+now;
		now=min(now+1,k-1);
	}
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++)
	{
		cout<<ans[vectex[i]];
	}

	return 0;
}