#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  int fh = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= fh;
}
int n, k, a[200010], no, b[200010], an, f[200010];
char ans[200010];
int main() {
  read(n);
  read(k);
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 1; i <= n; i++) read(b[i]);
  for (int i = 1; i <= n; i++) {
    f[a[i]]++;
    if (f[a[i]] == 1) no++;
    if (f[b[i]] == 1) no--;
    f[b[i]]--;
    ans[a[i]] = (char)(an + 'a');
    if (no == 0 && i != n) an = min(an + 1, k - 1);
  }
  if (an == k - 1) {
    puts("YES");
    for (int i = 1; i <= n; i++) cout << ans[i];
  } else
    puts("NO");
  return 0;
}
