#include <bits/stdc++.h>
using namespace std;
int n, k, cnt;
int viz1[200005], viz2[200005];
vector<int> G[200005], GR[200005];
stack<int> S;
char l, ans[200005];
void postDFS(int nod) {
  viz1[nod] = 1;
  for (int i = 0; i < G[nod].size(); i++)
    if (!viz1[G[nod][i]]) postDFS(G[nod][i]);
  S.push(nod);
}
void preDFS(int nod) {
  ans[nod] = l;
  viz2[nod] = 1;
  for (int i = 0; i < GR[nod].size(); i++)
    if (!viz2[GR[nod][i]]) preDFS(GR[nod][i]);
}
int main() {
  cin >> n >> k;
  int x, y;
  cin >> x;
  for (int i = 1; i < n; i++) {
    cin >> y;
    G[x].push_back(y);
    GR[y].push_back(x);
    x = y;
  }
  cin >> x;
  for (int i = 1; i < n; i++) {
    cin >> y;
    G[x].push_back(y);
    GR[y].push_back(x);
    x = y;
  }
  for (int i = 1; i <= n; i++)
    if (!viz1[i]) postDFS(i);
  l = 'a';
  while (!S.empty()) {
    int nod = S.top();
    S.pop();
    if (!viz2[nod]) {
      ++cnt;
      preDFS(nod);
      if (cnt < 26) ++l;
    }
  }
  if (cnt < k)
    cout << "NO";
  else {
    cout << "YES\n";
    for (int i = 1; i <= n; i++) cout << ans[i];
  }
}
