#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 8;
const long long maxn = 1e6 + 5;
const long long mo_num = 1e9 + 7;
long long n, m, a[maxn], b[maxn], ans;
set<long long> qian, hou;
vector<long long> Ans;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) cin >> b[i];
  for (long long i = 1; i <= n; i++) {
    if (hou.count(a[i])) {
      hou.erase(a[i]);
    } else
      qian.insert(a[i]);
    if (qian.count(b[i])) {
      qian.erase(b[i]);
    } else
      hou.insert(b[i]);
    if (qian.empty() && hou.empty()) Ans.push_back(i);
  }
  if (Ans.size() < m) {
    cout << "NO";
  } else {
    string t = string(n + 2, ' ');
    long long cnt = 0, have = 1;
    for (auto i : Ans) {
      char now = min('a' + cnt, (long long)'z');
      while (have <= i) {
        t[a[have++]] = (char)now;
      }
      cnt++;
    }
    cout << ("YES") << '\n';
    for (long long i = 1; i <= n; i++) cout << t[i];
    cout << '\n';
  }
  return 0;
}
