#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n), b(n), idx_a(n), sum(n + 1, 0), ans(n, 0);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    a[i]--;
    idx_a[a[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
    b[i]--;
  }
  for (int i = 0; i < n - 1; ++i) {
    if (idx_a[b[i]] > idx_a[b[i + 1]]) {
      sum[idx_a[b[i]]]--;
      sum[idx_a[b[i + 1]]]++;
    }
  }
  for (int i = 0; i < n; ++i) sum[i + 1] += sum[i];
  int j = 0;
  for (int i = 1; i < n; ++i) {
    if (j < 25 && sum[i - 1] == 0) j++;
    ans[a[i]] = j;
  }
  if (j + 1 >= k) {
    cout << "YES" << endl;
    for (int i = 0; i < n; ++i) cout << (char)('a' + ans[i]);
    cout << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
