#include <bits/stdc++.h>
const int MAXN = 2e5 + 5;
int G[MAXN];
int P[MAXN];
int Pinv[MAXN];
bool seen[MAXN];
std::vector<int> start;
char output[MAXN];
unsigned K;
int N, Q;
int prev;
void init() {
  prev = 0;
  for (int i = 1; i <= N; ++i) {
    seen[i] = false;
  }
}
bool solve() {
  for (int i = 1; i <= N; ++i) {
    int cur = P[i];
    int nxt = G[cur];
    seen[cur] = true;
    if (!seen[nxt]) {
      start.push_back(i);
      continue;
    }
    while (!start.empty() && (start.back() > Pinv[nxt])) {
      start.pop_back();
    }
  }
  return (start.size() >= K);
}
void display() {
  char c = 'a';
  --c;
  int j = 0;
  int M = start.size();
  for (int i = 1; i <= N; ++i) {
    if ((j < M) && (c < 'z') && (i == start[j])) {
      ++c;
      ++j;
    }
    output[P[i]] = c;
  }
  output[N + 1] = '\0';
  puts(output + 1);
}
int main() {
  scanf(" %d%u", &N, &K);
  init();
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &P[i]);
    Pinv[P[i]] = i;
  }
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &Q);
    G[prev] = Q;
    prev = Q;
  }
  if (solve()) {
    puts("YES");
    display();
  } else {
    puts("NO");
  }
  return 0;
}
