#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
const long long N = 800005;
long long head1[N], head2[N], cnt1, cnt2;
struct node {
  long long next, to;
} sxd1[N], sxd2[N];
inline void add1(long long u, long long v) {
  sxd1[++cnt1] = (node){head1[u], v};
  head1[u] = cnt1;
}
inline void add2(long long u, long long v) {
  sxd2[++cnt2] = (node){head2[u], v};
  head2[u] = cnt2;
}
long long n, k, temp, x;
long long dfn[N], low[N], tot, vis[N], kuai, belong[N];
stack<long long> st;
inline void tarjan(long long x) {
  dfn[x] = low[x] = ++tot;
  vis[x] = 1;
  st.push(x);
  for (register long long i = head1[x]; i; i = sxd1[i].next) {
    if (!dfn[sxd1[i].to]) {
      tarjan(sxd1[i].to);
      low[x] = min(low[x], low[sxd1[i].to]);
    } else if (vis[sxd1[i].to])
      low[x] = min(low[x], dfn[sxd1[i].to]);
  }
  if (dfn[x] == low[x]) {
    kuai++;
    long long at = 0;
    while (at != x && !st.empty()) {
      at = st.top();
      st.pop();
      vis[at] = 0;
      belong[at] = kuai;
    }
  }
}
long long ru[N], ans[N];
queue<long long> q;
inline void tp() {
  for (register long long i = 1; i <= kuai; i++)
    if (!ru[i]) q.push(i);
  long long at = 0;
  while (!q.empty()) {
    long long now = q.front();
    q.pop();
    ans[now] = at;
    if (at != 25) at++;
    for (register long long i = head2[now]; i; i = sxd2[i].next) {
      ru[sxd2[i].to]--;
      if (!ru[sxd2[i].to]) q.push(sxd2[i].to);
    }
  }
}
signed main() {
  n = read(), k = read();
  for (register long long i = 1; i <= 2; i++) {
    temp = read();
    for (register long long j = 1; j <= n - 1; j++) {
      x = read();
      add1(temp, x);
      temp = x;
    }
  }
  for (register long long i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  if (kuai < k) return puts("NO"), 0;
  for (register long long j = 1; j <= n; j++)
    for (register long long i = head1[j]; i; i = sxd1[i].next)
      if (belong[j] != belong[sxd1[i].to])
        add2(belong[j], belong[sxd1[i].to]), ru[belong[sxd1[i].to]]++;
  tp();
  puts("YES");
  for (register long long i = 1; i <= n; i++)
    cout << char(ans[belong[i]] + 'a');
  return 0;
}
