#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p1(n), p2(n);
  for (int i = 0; i < n; ++i) {
    cin >> p1[i];
    --p1[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> p2[i];
    --p2[i];
  }
  set<int> vals1, vals2;
  vector<int> rb;
  for (int i = 0; i < n; ++i) {
    if (vals2.count(p1[i])) {
      vals2.erase(p1[i]);
    } else {
      vals1.insert(p1[i]);
    }
    if (vals1.count(p2[i])) {
      vals1.erase(p2[i]);
    } else {
      vals2.insert(p2[i]);
    }
    if (vals1.empty() && vals2.empty()) {
      rb.push_back(i);
    }
  }
  if (int(rb.size()) < k) {
    cout << "NO" << endl;
  } else {
    string s(n, ' ');
    int l = 0;
    for (int it = 0; it < int(rb.size()); ++it) {
      int r = rb[it];
      char c = 'a' + min(it, 25);
      for (int i = l; i <= r; ++i) {
        s[p1[i]] = c;
      }
      l = r + 1;
    }
    cout << "YES" << endl << s << endl;
  }
  return 0;
}
