#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  vector<long long int> v1(n);
  vector<long long int> v2(n);
  for (long long int i = 0; i < n; i++) cin >> v1[i];
  for (long long int i = 0; i < n; i++) cin >> v2[i];
  set<long long int> s1, s2;
  vector<long long int> v;
  v.push_back(-1);
  for (long long int i = 0; i < n; i++) {
    if (s2.find(v1[i]) != s2.end())
      s2.erase(v1[i]);
    else
      s1.insert(v1[i]);
    if (s1.find(v2[i]) != s1.end())
      s1.erase(v2[i]);
    else
      s2.insert(v2[i]);
    if (s1.size() == 0 && s2.size() == 0) {
      v.push_back(i);
    }
  }
  if (v.size() < k + 1) {
    cout << "NO";
    return 0;
  }
  char u = 'a';
  vector<char> c(n + 1);
  for (long long int i = 1; i < v.size(); i++) {
    if (i > 26) {
      long long int j = v[i - 1] + 1;
      while (j <= v[i]) {
        c[v1[j]] = 'z';
        j++;
      }
    } else {
      long long int j = v[i - 1] + 1;
      while (j <= v[i]) {
        c[v1[j]] = u;
        j++;
      }
      u = (char)(u + 1);
    }
  }
  cout << "YES" << endl;
  for (long long int i = 1; i < n + 1; i++) cout << c[i];
  return 0;
}
