#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
vector<vector<long long> > g(N), rg(N);
vector<long long> order, component;
bool vis[N];
char ans[N];
void dfs1(long long src) {
  vis[src] = 1;
  for (auto i : g[src]) {
    if (!vis[i]) {
      dfs1(i);
    }
  }
  order.push_back(src);
}
void dfs2(long long src) {
  vis[src] = 1;
  component.push_back(src);
  for (auto i : rg[src]) {
    if (!vis[i]) {
      dfs2(i);
    }
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n - 1; i++) {
    g[a[i]].push_back(a[i + 1]);
    rg[a[i + 1]].push_back(a[i]);
  }
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n - 1; i++) {
    g[a[i]].push_back(a[i + 1]);
    rg[a[i + 1]].push_back(a[i]);
  }
  memset(vis, 0, sizeof(vis));
  for (long long i = 1; i < n + 1; i++) {
    if (!vis[i]) {
      dfs1(i);
    }
  }
  memset(vis, 0, sizeof(vis));
  long long z = 0;
  string ff = "abcdefghijklmnopqrstuvwxyz";
  for (long long i = 0; i < n; i++) {
    long long v = order[n - 1 - i];
    if (!vis[v]) {
      dfs2(v);
      for (auto j : component) {
        ans[j] = ff[min(z, k - 1)];
      }
      z++;
      component.clear();
    }
  }
  if (z < k) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
  for (long long i = 1; i < n + 1; i++) {
    cout << ans[i];
  }
  cout << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tests = 1;
  while (tests--) {
    solve();
  }
  return 0;
}
