#include <bits/stdc++.h>
using namespace std;
void input(vector<int>& vec, int n) {
  for (int i = 0; i < n; i++) cin >> vec[i];
}
int main() {
  int n, k, i, j, partitions = 0, diff = 0, last_partition = 0;
  cin >> n >> k;
  char filler = 'a';
  string ret(n, '_');
  vector<bool> state(n + 1, false);
  vector<int> p(n), q(n);
  input(p, n);
  input(q, n);
  for (i = 0; i < n; i++) {
    if (state[p[i]]) {
      --diff;
      state[p[i]] = false;
    } else {
      ++diff;
      state[p[i]] = true;
    }
    if (state[q[i]]) {
      --diff;
      state[q[i]] = false;
    } else {
      ++diff;
      state[q[i]] = true;
    }
    if (!diff) {
      partitions++;
      for (j = last_partition; j <= i; j++) ret[p[j] - 1] = filler;
      if (filler < 'z') filler++;
      last_partition = i + 1;
    }
  }
  if (partitions < k)
    cout << "NO\n";
  else {
    cout << "YES\n";
    cout << ret << "\n";
  }
  return 0;
}
