#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 2e5 + 10;
int n, k, a[N], b[N], idx[N], kp = -1;
char lc = 'a' - 1, res[N];
int main() {
  ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    idx[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    if (kp < i && k > 0) {
      lc++;
      k--;
    }
    res[b[i]] = lc;
    kp = max(kp, idx[b[i]]);
  }
  if (k == 0) {
    cout << "YES\n" << (res + 1);
  } else {
    cout << "NO\n";
  }
}
