#include <bits/stdc++.h>
using namespace std;
int n, k, a[200001], b[200001], F[200001], Cnt[200001], d, dem = 0;
char Ch[200001], u = 'a';
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  int x = 0;
  for (int i = 1; i <= n; i++) {
    F[a[i]]++;
    F[b[i]]--;
    if (F[a[i]] == 0) d++;
    if (F[b[i]] == 0 && b[i] != a[i]) d++;
    if (d == i - x) {
      Cnt[++dem] = i;
      x = i;
      d = 0;
    }
  }
  if (dem < k) {
    cout << "NO";
    return 0;
  }
  int j = 1;
  for (int i = 1; i <= n; i++) {
    Ch[a[i]] = u;
    if (i == Cnt[j] && j < 26) u = char(u + 1), j++;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) cout << Ch[i];
}
