#include <bits/stdc++.h>
using namespace std;
int n, k, a[200010], b[200010], fa[200010], c[200010], s = 0;
int i1 = 1, i2 = 1;
int las = 1, xb = 1, t = 0;
char ch[200010];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  while (true) {
    if (i1 > n || i2 > n) break;
    int fx = find(a[i1]), fy = find(b[i2]);
    if (fx == fy) {
      if (i1 == i2) {
        c[++s] = i1;
        i1++;
        i2++;
      } else
        i2++;
    } else
      fa[find(a[i1])] = find(a[i1 + 1]), i1++;
  }
  if (s < k) {
    printf("NO\n");
    return 0;
  }
  while (true) {
    if (xb > s) {
      break;
    }
    for (int i = las; i <= c[xb]; i++) ch[a[i]] = t + 'a';
    las = c[xb++] + 1;
    if (xb <= k) t++;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) cout << ch[i];
  return 0;
}
