#include <bits/stdc++.h>
using namespace std;
int a[200007], b[200007];
char ans[200007];
int n, k;
int main() {
  cin >> n >> k;
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    cin >> a[i];
    a[i]--;
  }
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    cin >> b[i];
    b[i]--;
  }
  set<int> s1, s2;
  vector<int> v;
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    int p = a[i], q = b[i];
    if (s2.count(p))
      s2.erase(p);
    else
      s1.insert(p);
    if (s1.count(q))
      s1.erase(q);
    else
      s2.insert(q);
    if (s1.empty() && s2.empty()) v.push_back(i);
  }
  if (v.size() < k) {
    cout << "NO" << endl;
    exit(0);
  }
  int l = 0, r = 0;
  char cur = 'a';
  for (int(i) = 0; (i) < (int)(v.size()); (i)++) {
    r = v[i];
    for (int j = l; j <= r; j++) {
      ans[a[j]] = cur;
    }
    l = r + 1;
    cur = min(char(cur + 1), 'z');
  }
  cout << "YES" << endl;
  puts(ans);
  return 0;
}
