#include <bits/stdc++.h>
using namespace std;
int n, k, P[(200010)], Q[(200010)], ret[(200010)], C[(200010)], ans[(200010)];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9')
    ch == '-' ? f = -1, ch = getchar() : ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return x * f;
}
signed main() {
  n = read(), k = read();
  for (int i = 1; i <= n; ++i) P[i] = read();
  for (int i = 1; i <= n; ++i) Q[i] = read();
  for (int i = 1; i <= n; ++i) ret[P[i]] = i;
  for (int i = 2; i <= n; ++i)
    if (ret[Q[i]] < ret[Q[i - 1]])
      C[ret[Q[i]]] += ret[Q[i - 1]] - ret[Q[i]],
          C[ret[Q[i - 1]]] -= ret[Q[i - 1]] - ret[Q[i]];
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (sum)
      ans[i] = ans[i - 1];
    else
      ans[i] = ans[i - 1] + 1;
    sum += C[i];
  }
  if (ans[n] < k)
    puts("NO");
  else {
    puts("YES");
    for (int i = 1; i <= n; ++i) printf("%c", min(ans[ret[i]], k) + 'a' - 1);
    puts("");
  }
  return 0;
}
