#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = int(2e5 + 10);
vector<int> adj[N], radj[N], nadj[N];
int bel[N];
int cor[N];
int cchar[N];
int ncor[N];
int p[N], q[N];
vector<int> top, top1;
int comp;
void dfs(int u) {
  cor[u] = 1;
  for (int v : adj[u]) {
    if (cor[v] == 0) {
      dfs(v);
    }
  }
  top.push_back(u);
}
void dfs1(int u) {
  bel[u] = comp;
  for (int v : radj[u]) {
    if (bel[v] == 0) {
      dfs1(v);
    }
  }
}
void dfs2(int u) {
  ncor[u] = 1;
  for (int v : nadj[u]) {
    if (ncor[v] == 0) {
      dfs2(v);
    }
  }
  top1.push_back(u);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &q[i]);
  }
  for (int i = 1; i < n; i++) {
    adj[p[i]].push_back(p[i - 1]);
    radj[p[i - 1]].push_back(p[i]);
  }
  for (int i = 1; i < n; i++) {
    adj[q[i]].push_back(q[i - 1]);
    radj[q[i - 1]].push_back(q[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (!cor[i]) {
      dfs(i);
    }
  }
  for (int k = int(top.size()) - 1; k >= 0; k--) {
    int u = top[k];
    if (bel[u] == 0) {
      comp++;
      dfs1(u);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int v : adj[i]) {
      if (bel[v] != bel[i]) {
        nadj[bel[i]].push_back(bel[v]);
      }
    }
  }
  for (int i = 1; i <= comp; i++) {
    if (ncor[i] == 0) {
      dfs2(i);
    }
  }
  if (comp < m) {
    printf("NO\n");
  } else {
    printf("YES\n");
    char c = 'z';
    for (int k = int(top1.size()) - 1; k >= 0; k--) {
      cchar[top1[k]] = c;
      c--;
      c = max(c, 'a');
    }
    for (int i = 1; i <= n; i++) {
      printf("%c", cchar[bel[i]]);
    }
    printf("\n");
  }
  return 0;
}
