#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 1;
int n, k;
int p[maxN], q[maxN];
int mapp[maxN], Right[maxN];
int res[maxN], finalres[maxN];
void ReadInput() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    mapp[p[i]] = i;
  }
  for (int i = 1; i <= n; ++i) cin >> q[i];
}
void Solve() {
  fill(Right + 1, Right + n + 1, 0);
  for (int i = 1; i < n; ++i) {
    int a = mapp[q[i]], b = mapp[q[i + 1]];
    if (a > b) Right[b] = a;
  }
  int cnt = 0, maxR = -1;
  for (int i = 1; i <= n; ++i) {
    if (i > maxR) ++cnt;
    if (Right[i] > maxR) maxR = Right[i];
    res[i] = cnt;
  }
  if (cnt < k) {
    cout << "NO";
    return;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) finalres[p[i]] = min(res[i], k);
  for (int i = 1; i <= n; ++i) cout << (char)(finalres[i] - 1 + 'a');
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ReadInput();
  Solve();
}
