#include <bits/stdc++.h>
using namespace std;
int n, k, ks, cnt, lena, lenb;
int a[200005], b[200005], ans[200005];
char c[200005];
bool visa[200005], visb[200005];
int main() {
  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++) {
    if (visb[a[i]] == 1) {
      visb[a[i]] = 0;
      lenb--;
    } else {
      visa[a[i]] = 1;
      lena++;
    }
    if (visa[b[i]] == 1) {
      visa[b[i]] = 0;
      lena--;
    } else {
      visb[b[i]] = 1;
      lenb++;
    }
    if (lena == 0 && lenb == 0) {
      cnt++;
      ans[cnt] = i;
    }
  }
  if (cnt < k) {
    printf("NO");
    return 0;
  }
  printf("YES\n");
  ks = 1;
  int r;
  char ch;
  for (int i = 1; i <= cnt; i++) {
    r = ans[i];
    ch = 'a' + min(i, 26) - 1;
    for (int j = ks; j <= r; j++) c[a[j]] = ch;
    ks = r + 1;
  }
  printf("%s", c + 1);
  return 0;
}
