#include <bits/stdc++.h>
using namespace std;
int a[200200], b[200200], c[200200], book[200200], bookk[200200];
char s[200200];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    book[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (i > 1 && book[b[i]] < book[b[i - 1]]) {
      c[book[b[i]]]++;
      c[book[b[i - 1]]]--;
    }
  }
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    if (flag)
      bookk[i] = bookk[i - 1];
    else
      bookk[i] = bookk[i - 1] + 1;
    flag += c[i];
  }
  if (bookk[n] < k)
    puts("NO");
  else {
    printf("YES\n");
    for (int i = 1; i <= n; i++) {
      int w = min(bookk[book[i]], k);
      printf("%c", w + 'a' - 1);
    }
  }
  return 0;
}
