#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long t[200002], v[200002];
set<long long> a, b;
vector<long long> w;
int main() {
  cin >> n >> k;
  w.push_back(0);
  k++;
  for (int i = 0; i < n; i++) cin >> t[i];
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) {
    if (a.count(v[i]))
      a.erase(v[i]);
    else
      b.insert(v[i]);
    if (b.count(t[i]))
      b.erase(t[i]);
    else
      a.insert(t[i]);
    if (a.empty() && b.empty()) w.push_back(i + 1);
    if (w.size() == k) break;
  }
  w[k - 1] = n;
  if (w.size() < k) return cout << "NO", 0;
  cout << "YES\n";
  string res(n, ' ');
  for (int i = 1; i < k; i++)
    for (int j = w[i - 1]; j < w[i]; j++) res[t[j] - 1] = 'a' + i - 1;
  cout << res;
  return 0;
}
