#include <bits/stdc++.h>
using namespace std;
int l[1234567], r[1234567], a[1234567], b[1234567], v[1234567];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n; ++i) {
    l[a[i]] = r[a[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    if (i < l[b[i]]) l[b[i]] = i;
    if (i > r[b[i]]) r[b[i]] = i;
  }
  int x = 0, h = -1;
  for (int i = 0; i < n; ++i) {
    int y = max(r[a[i]], r[b[i]]);
    if (i > h) {
      x = min(x + 1, k);
    }
    h = max(h, y);
    v[i] = x;
  }
  if (x < k)
    cout << "NO" << endl;
  else {
    string res(n, ' ');
    for (int i = 0; i < n; ++i) res[a[i] - 1] = v[i] + 'a' - 1;
    cout << "YES" << endl;
    cout << res << endl;
  }
  return 0;
}
