#include <bits/stdc++.h>
using namespace std;
struct Graph {
  struct Edge {
    int f, t, nxt;
  } edge[400005 * 2];
  int head[200005], etot;
  void add_edge(int f, int t) {
    edge[++etot] = (Edge){f, t, head[f]};
    head[f] = etot;
  }
};
Graph g, ng;
template <typename Tp>
void read(Tp &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c & 15);
    c = getchar();
  }
  x *= f;
}
int dfn[200005], low[200005], ins[200005], c[200005], cnt, tot;
stack<int> st;
void dfs(int x) {
  dfn[x] = low[x] = ++tot;
  st.push(x);
  ins[x] = 1;
  for (int i = g.head[x]; i; i = g.edge[i].nxt) {
    int y = g.edge[i].t;
    if (!dfn[y]) {
      dfs(y);
      low[x] = min(low[x], low[y]);
    } else if (ins[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] == low[x]) {
    int y = st.top();
    st.pop();
    c[y] = ++cnt;
    ins[y] = 0;
    while (y != x) {
      y = st.top();
      st.pop();
      c[y] = cnt;
      ins[y] = 0;
    }
  }
}
int n, k, rd[200005];
int p[200005], q[200005];
map<pair<int, int>, int> mp;
int dis[200005];
queue<int> qq;
signed main() {
  int x, y;
  read(n);
  read(k);
  for (int i = 1; i <= n; i++) {
    read(p[i]);
    if (i > 1) g.add_edge(p[i - 1], p[i]);
  }
  for (int i = 1; i <= n; i++) {
    read(q[i]);
    if (i > 1) g.add_edge(q[i - 1], q[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (!dfn[i]) dfs(i);
  }
  for (int i = 1; i <= g.etot; i++) {
    if (c[g.edge[i].f] == c[g.edge[i].t]) continue;
    if (mp[make_pair(c[g.edge[i].f], c[g.edge[i].t])]) continue;
    mp[make_pair(c[g.edge[i].f], c[g.edge[i].t])] = 1;
    rd[c[g.edge[i].t]]++;
    ng.add_edge(c[g.edge[i].f], c[g.edge[i].t]);
  }
  for (int i = 1; i <= cnt; i++) {
    if (!rd[i]) qq.push(i), dis[i] = 1;
  }
  while (!qq.empty()) {
    x = qq.front();
    qq.pop();
    for (int i = ng.head[x]; i; i = ng.edge[i].nxt) {
      y = ng.edge[i].t;
      dis[y] = min(dis[x] + 1, 26);
      if (--rd[y] == 0) qq.push(y);
    }
  }
  int mx = 0;
  for (int i = 1; i <= cnt; i++) mx = max(mx, dis[i]);
  if (mx < k)
    puts("NO");
  else {
    puts("YES");
    for (int i = 1; i <= n; i++) cout << (char)(dis[c[i]] + 'a' - 1);
  }
  return 0;
}
