#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> b(n);
  for (int &i : a) cin >> i;
  for (int &i : b) cin >> i;
  map<int, bool> a_map;
  map<int, bool> b_map;
  vector<pair<int, int> > blocks;
  int last = 0;
  for (int i = 0; i < n; ++i) {
    a_map[a[i]] = 1;
    b_map[b[i]] = 1;
    if (b_map[a[i]]) {
      a_map.erase(a[i]);
      b_map.erase(a[i]);
    }
    if (a[i] != b[i] && a_map[b[i]]) {
      a_map.erase(b[i]);
      b_map.erase(b[i]);
    }
    if (a_map.empty()) {
      blocks.push_back({last, i});
      last = i + 1;
    }
  }
  if (blocks.size() < k) return cout << "NO", 0;
  vector<char> ans(n);
  for (int i = 0; i < blocks.size(); ++i) {
    for (int j = blocks[i].first; j <= blocks[i].second; ++j) {
      if (i > 25)
        ans[a[j] - 1] = 'z';
      else
        ans[a[j] - 1] = 'a' + i;
    }
  }
  cout << "YES\n";
  for (char &i : ans) cout << i;
  return 0;
}
