#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int A[N], B[N];
int dfn[N], low[N], sccno[N], scc_cnt, tot;
int in[N];
char ans[N], ans1[N];
vector<int> mp[N], scc[N], mp1[N];
stack<int> s;
void dfs(int u) {
  low[u] = dfn[u] = ++tot;
  s.push(u);
  for (int i = 0; i < mp[u].size(); i++) {
    int v = mp[u][i];
    if (!dfn[v]) {
      dfs(v);
      low[u] = min(low[v], low[u]);
    } else if (!sccno[v]) {
      low[u] = min(low[u], dfn[v]);
    }
  }
  if (low[u] == dfn[u]) {
    ++scc_cnt;
    while (1) {
      int x = s.top();
      s.pop();
      sccno[x] = scc_cnt;
      scc[scc_cnt].push_back(x);
      if (x == u) break;
    }
  }
}
int main() {
  int n, k;
  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++) {
    mp[A[i]].push_back(A[i + 1]);
    mp[B[i]].push_back(B[i + 1]);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i);
  for (int i = 1; i <= scc_cnt; i++) {
    for (int j = 0; j < scc[i].size(); j++) {
      int u = scc[i][j];
      for (int k = 0; k < mp[u].size(); k++) {
        int v = mp[u][k];
        if (sccno[v] != i) {
          mp1[i].push_back(sccno[v]);
          in[sccno[v]]++;
        }
      }
    }
  }
  queue<int> q;
  int cnt = 0;
  for (int i = 1; i <= scc_cnt; i++)
    if (in[i] == 0) q.push(i);
  int id = 0;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (id < 26) id++;
    ans[x] = id + 'a' - 1;
    for (int i = 0; i < mp1[x].size(); i++) {
      int v = mp1[x][i];
      if (--in[v] == 0) {
        q.push(v);
      }
    }
  }
  if (id < k)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 1; i <= n; i++) ans1[i] = ans[sccno[i]];
    for (int i = 1; i <= n; i++) putchar(ans1[i]);
  }
}
