#include <bits/stdc++.h>
using namespace std;
template <class R>
inline void Readin(R &K) {
  bool F = K = 0;
  char C = getchar();
  while (C < '0' || C > '9') {
    if (C == '-') F = 1;
    C = getchar();
  }
  while (C <= '9' && C >= '0') K = (K << 1) + (K << 3) + C - '0', C = getchar();
  if (F) K = -K;
}
template <class R>
inline bool Checkmax(R &A, R B) {
  return A < B ? A = B, 1 : 0;
}
template <class R>
inline bool Checkmin(R &A, R B) {
  return A > B ? A = B, 1 : 0;
}
const int MaxN = 200000 + 10;
int N, K;
int P[MaxN], Q[MaxN], Inv[MaxN], Cnt;
char Ans[MaxN];
int main() {
  Readin(N);
  Readin(K);
  for (register int i = 0; ++i <= N;) {
    Readin(P[i]);
    Inv[P[i]] = i;
  }
  for (register int i = 0; ++i <= N;) {
    register int X;
    Readin(X);
    Q[i] = Inv[X];
  }
  for (register int i = 0, Now = 0, Last = 0; ++i <= N;) {
    Checkmax(Now, Q[i]);
    if (Now == i) {
      ++Cnt;
      for (register int i = Last; ++i <= Now;)
        Ans[P[i]] = 'a' + min(Cnt, 26) - 1;
      Last = Now;
    }
  }
  if (Cnt < K) return not printf("NO\n");
  printf("YES\n");
  for (register int i = 0; ++i <= N;) {
    putchar(Ans[i]);
  }
  return not printf("\n");
}
