#include <bits/stdc++.h>
using namespace std;
int n, k;
int p[210000];
int q[210000];
vector<int> edgeList[210000];
vector<int> edgeListTranspose[210000];
bool visited[210000];
stack<int> order;
vector<vector<int>> sccList;
int answer[210000];
void in() {
  scanf("%d %d", &n, &k);
  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++) {
    edgeList[p[i - 1]].push_back(p[i]);
    edgeListTranspose[p[i]].push_back(p[i - 1]);
  }
  for (int i = 1; i < n; i++) {
    edgeList[q[i - 1]].push_back(q[i]);
    edgeListTranspose[q[i]].push_back(q[i - 1]);
  }
}
void dfs(int root) {
  if (visited[root]) return;
  visited[root] = true;
  for (auto &x : edgeList[root]) {
    if (visited[x]) continue;
    dfs(x);
  }
  order.push(root);
}
void dfs(int root, vector<int> &scc) {
  if (visited[root]) return;
  visited[root] = true;
  scc.push_back(root);
  for (auto &x : edgeListTranspose[root]) {
    if (visited[x]) continue;
    dfs(x, scc);
  }
}
void getSCC() {
  for (int i = 1; i <= n; i++) visited[i] = false;
  while (!order.empty()) {
    int v = order.top();
    order.pop();
    if (visited[v]) continue;
    vector<int> newSCC;
    dfs(v, newSCC);
    sccList.push_back(newSCC);
  }
}
int main() {
  in();
  for (int i = 1; i <= n; i++) dfs(i);
  getSCC();
  if (k > sccList.size())
    printf("NO\n");
  else {
    printf("YES\n");
    int sccIdx = 0;
    for (auto &x : sccList) {
      for (auto &y : x) answer[y] = sccIdx;
      sccIdx++;
    }
    for (int i = 1; i <= n; i++)
      printf("%c", answer[i] + 'a' <= 'z' ? answer[i] + 'a' : 'z');
    printf("\n");
  }
}
