#include <bits/stdc++.h>
using namespace std;
vector<bool> visited;
vector<vector<long long> > adj;
vector<vector<long long> > rev;
vector<long long> order;
vector<char> col;
void dfs1(long long x) {
  visited[x] = true;
  for (auto y : adj[x]) {
    if (!visited[y]) dfs1(y);
  }
  order.push_back(x);
}
void dfs2(long long x, char colour) {
  visited[x] = true;
  col[x] = colour;
  for (auto y : rev[x]) {
    if (!visited[y]) {
      dfs2(y, colour);
    }
  }
}
int32_t main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j;
  long long n, k;
  cin >> n >> k;
  adj.resize(n);
  rev.resize(n);
  long long p[n];
  for (i = 0; i < n; i++) cin >> p[i];
  for (i = 0; i < n - 1; i++) {
    long long u = p[i + 1] - 1;
    long long v = p[i] - 1;
    adj[v].push_back(u);
    rev[u].push_back(v);
  }
  for (i = 0; i < n; i++) cin >> p[i];
  for (i = 0; i < n - 1; i++) {
    long long u = p[i + 1] - 1;
    long long v = p[i] - 1;
    adj[v].push_back(u);
    rev[u].push_back(v);
  }
  visited.assign(n, false);
  for (long long i = 0; i < n; i++) {
    if (!visited[i]) dfs1(i);
  }
  visited.assign(n, false);
  reverse(order.begin(), order.end());
  vector<long long> condensed[n];
  char colour = 'a';
  col.resize(n);
  for (i = 0; i < n; i++) {
    long long v = order[i];
    if (!visited[v]) {
      dfs2(v, colour);
      if (colour != 'z') ++colour;
    }
  }
  set<long long> numCols;
  for (i = 0; i < n; i++) {
    numCols.insert(col[i]);
  }
  if (numCols.size() >= k)
    cout << "YES"
         << "\n";
  else {
    cout << "NO"
         << "\n";
    return 0;
  }
  for (auto ch : col) cout << ch;
  cout << "\n";
  return 0;
}
