#include <bits/stdc++.h>
using namespace std;
int n, k;
void solve() {
  cin >> n >> k;
  vector<int> p(n + 1), q(n + 1), last(n + 1);
  vector<pair<int, int>> segs;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    last[p[i]] = i;
  }
  for (int j = 1; j <= n; ++j) {
    cin >> q[j];
    last[q[j]] = max(last[q[j]], j);
  }
  int pos = 1;
  int prev = 1;
  for (int i = 1; i <= n; ++i) {
    if (i > pos) {
      segs.push_back({prev, i - 1});
      prev = i;
    }
    pos = max(pos, last[p[i]]);
  }
  segs.push_back({prev, n});
  if ((int)segs.size() < k) {
    cout << "NO";
    return;
  } else {
    cout << "YES\n";
    vector<char> s(n + 1);
    int color = 0;
    for (auto &pa : segs) {
      for (int i = pa.first; i <= pa.second; ++i) {
        s[p[i]] = 'a' + color;
      }
      ++color;
      if (color > 25) color = 25;
    }
    for (int i = 1; i <= n; ++i) cout << s[i];
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
