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