#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005];
vector<int> adj[200005], rev[200005], grafo[200005];
vector<int> idGroup[200005];
char res[200005], last;
void topo(int u, int *vis, stack<int> &topp) {
  vis[u] = 1;
  for (int v : adj[u]) {
    if (!vis[v]) topo(v, vis, topp);
  }
  topp.push(u);
}
void solve(int u, int *vis, vector<int> &cmp) {
  vis[u] = 1;
  cmp.push_back(u);
  for (int v : rev[u]) {
    if (!vis[v]) solve(v, vis, cmp);
  }
}
void go(int u, int *vis) {
  vis[u] = 1;
  last = min((char)(last + 1), 'z');
  for (int v : idGroup[u]) res[v] = last;
  for (int v : grafo[u])
    if (u != v) go(v, vis);
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  for (int i = 0; i < n - 1; i++) {
    adj[a[i]].push_back(a[i + 1]);
    rev[a[i + 1]].push_back(a[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    adj[b[i]].push_back(b[i + 1]);
    rev[b[i + 1]].push_back(b[i]);
  }
  stack<int> topp;
  int vis[200005];
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) topo(i, vis, topp);
  memset(vis, 0, sizeof vis);
  int cnt = 0;
  vector<int> nodes;
  while (!topp.empty()) {
    int u = topp.top();
    topp.pop();
    if (!vis[u]) {
      cnt++;
      vector<int> comp;
      solve(u, vis, comp);
      sort(comp.begin(), comp.end());
      set<int> fwd, backwd;
      for (int u : comp) {
        for (int v : adj[u])
          if (!binary_search(comp.begin(), comp.end(), v)) fwd.insert(v);
        for (int v : rev[u])
          if (!binary_search(comp.begin(), comp.end(), v)) backwd.insert(v);
      }
      for (int v : backwd) grafo[v].push_back(comp[0]);
      for (int v : comp) idGroup[comp[0]].push_back(v);
      nodes.push_back(comp[0]);
    }
  }
  if (cnt < k) {
    cout << "NO" << endl;
    return 0;
  }
  memset(vis, 0, sizeof vis);
  last = 'a' - 1;
  for (int x : nodes)
    if (!vis[x]) go(x, vis);
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) cout << res[i];
  cout << endl;
  return 0;
}
