#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int mx[maxn];
char s[maxn];
int q[maxn];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    mx[a] = i;
  }
  s[n + 1] = '\0';
  for (int i = 1; i <= n; i++) {
    cin >> q[i];
  }
  int m = 1;
  int c = 1;
  for (int i = 1; i <= n; i++) {
    m = max(m, mx[q[i]]);
    s[q[i]] = c + 'a' - 1;
    if (i < n && i == m && c < k) {
      c++;
    }
  }
  if (c < k)
    cout << "NO";
  else
    cout << "YES" << endl << s + 1;
}
