#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
vector<int> g[MAXN];
int n, lw[MAXN], idx[MAXN], qidx, cmp[MAXN], qcmp;
stack<int> st;
void tjn(int u) {
  lw[u] = idx[u] = ++qidx;
  st.push(u);
  cmp[u] = -2;
  for (int v : g[u]) {
    if (!idx[v] || cmp[v] == -2) {
      if (!idx[v]) tjn(v);
      lw[u] = min(lw[u], lw[v]);
    }
  }
  if (lw[u] == idx[u]) {
    int x, l = -1;
    do {
      x = st.top();
      st.pop();
      cmp[x] = qcmp;
    } while (x != u);
    qcmp++;
  }
}
void scc() {
  memset(idx, 0, sizeof(idx));
  qidx = 0;
  memset(cmp, -1, sizeof(cmp));
  qcmp = 0;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i)
    if (!idx[i]) tjn(i);
}
int a[MAXN], b[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int k;
  cin >> n >> k;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) cin >> a[i], a[i]--;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) cin >> b[i], b[i]--;
  for (int i = 0, ThxDem = n - 1; i < ThxDem; ++i)
    g[a[i]].push_back(a[i + 1]), g[b[i]].push_back(b[i + 1]);
  scc();
  if (qcmp < k) cout << "NO\n", exit(0);
  map<int, char> mp;
  char now = 'a';
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    if (!mp.count(cmp[a[i]]))
      mp[cmp[a[i]]] = now, now = min('z', char(now + 1));
  }
  cout << "YES\n";
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) cout << mp[cmp[i]];
  cout << "\n";
}
