#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
int seen[maxn], low[maxn], num[maxn], N, K, counter, comps;
vector<int> graph[maxn], s;
char str[maxn], act;
void dfs(int u) {
  seen[u] = 1;
  low[u] = num[u] = ++counter;
  s.push_back(u);
  for (int i = 0; i < graph[u].size(); i++) {
    int v = graph[u][i];
    if (!num[v]) dfs(v);
    if (seen[v]) low[u] = min(low[u], low[v]);
  }
  if (low[u] == num[u]) {
    while (1) {
      int v = s.back();
      s.pop_back();
      seen[v] = 0;
      str[v] = act;
      if (u == v) break;
    }
    comps++;
    if (act != 'a') {
      act--;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> K;
  vector<int> A(N);
  for (int j = 0; j < 2; j++) {
    for (int i = 0; i < N; i++) {
      cin >> A[i];
      A[i]--;
    }
    for (int i = 0; i < N - 1; i++) {
      graph[A[i]].push_back(A[i + 1]);
    }
  }
  act = 'z';
  for (int i = N - 1; i >= 0; i--) {
    if (!num[i]) dfs(i);
  }
  if (comps < K) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < N; i++) cout << str[i];
  cout << '\n';
  return 0;
}
