#include <bits/stdc++.h>
const int N = 200010;
int n, k, sa, sb, cnt;
char c[N];
int a[N], b[N], va[N], vb[N], blk[N];
inline int min(int x, int y) { return (x < y ? x : y); }
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) {
    vb[a[i]] ? (vb[a[i]] = 0, --sb) : (va[a[i]] = 1, ++sa);
    va[b[i]] ? (va[b[i]] = 0, --sa) : (vb[b[i]] = 1, ++sb);
    sa || sb || (blk[++cnt] = i);
  }
  if (cnt < k) return puts("NO"), 0;
  int l = 1, r = 0;
  char ch;
  for (int i = 1; i <= cnt; ++i, l = r + 1) {
    r = blk[i];
    ch = 'a' + min(i, 26) - 1;
    for (int j = l; j <= r; ++j) c[a[j]] = ch;
  }
  printf("YES\n%s", c + 1);
  return 0;
}
