#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int p[N], rp[N], e[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> p[i], rp[p[i]] = i;
  int last = 0;
  for (int i = 1; i <= n; i++) {
    int cur;
    cin >> cur;
    if (last)
      if (rp[last] > rp[cur]) e[rp[cur]]++, e[rp[last]]--;
    last = cur;
  }
  vector<char> Ans(n);
  char cur = 'a';
  for (int i = 1; i <= n; i++) {
    Ans[p[i] - 1] = cur;
    e[i] += e[i - 1];
    if (i < n && !e[i] && k > 1) k--, cur++;
  }
  if (k > 1)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int i = 0; i < n; i++) cout << Ans[i];
    cout << endl;
  }
  return 0;
}
