#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[200005], b[200005];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", b + i);
  }
  set<int> aa, bb;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    if (aa.count(b[i])) {
      aa.erase(b[i]);
    } else {
      bb.insert(b[i]);
    }
    if (bb.count(a[i])) {
      bb.erase(a[i]);
    } else {
      aa.insert(a[i]);
    }
    if (aa.empty() && bb.empty()) {
      ans.push_back(i);
    }
  }
  if (ans.size() >= k) {
    puts("YES");
    string s(n, ' ');
    int l = 0;
    for (int i = 0; i < ans.size(); i++) {
      int r = ans[i];
      char c = 'a' + min(i, 25);
      for (int j = l; j <= r; j++) {
        s[a[j] - 1] = c;
      }
      l = r + 1;
    }
    cout << s << '\n';
    return 0;
  }
  puts("NO");
  return 0;
}
