#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int a[n], b[n];
  for (int i = 0; i < n; i++) scanf("%d", a + i), a[i]--;
  for (int i = 0; i < n; i++) scanf("%d", b + i), b[i]--;
  set<int> s1, s2;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    if (s1.count(b[i]))
      s1.erase(b[i]);
    else
      s2.insert(b[i]);
    if (s2.count(a[i]))
      s2.erase(a[i]);
    else
      s1.insert(a[i]);
    if (s1.empty() && s2.empty()) {
      v.push_back(i);
    }
  }
  if (v.size() < k) {
    printf("NO\n");
    return 0;
  }
  string s(n, ' ');
  int idx = 0;
  for (int i = 0; i < v.size(); i++) {
    int ex = v[i];
    for (int j = idx; j <= ex; j++) {
      s[a[j]] = ('a' + min(25, i));
    }
    idx = ex + 1;
  }
  printf("YES\n%");
  cout << s << "\n";
  return 0;
}
