#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 200100;
const long long INF = 2000000100;
const long long MOD = 998244353;
int N, K;
int P[MAXN], revP[MAXN], Q[MAXN], C[MAXN], ans[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> K;
  for (int i = 1; i <= N; i++) {
    cin >> P[i];
    revP[P[i]] = i;
  }
  for (int i = 1; i <= N; i++) {
    cin >> Q[i];
    Q[i] = revP[Q[i]];
  }
  int m = -39;
  for (int i = 1; i <= N; i++) {
    m = max(m, Q[i]);
    if (m == i) {
      C[i] = 1;
    }
  }
  char c = 'a';
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    ans[P[i]] = c;
    if (C[i] == 1) {
      c = min(c + 1, (int)'z');
      cnt++;
    }
  }
  if (cnt >= K) {
    cout << "YES\n";
    for (int i = 1; i <= N; i++) {
      cout << (char)ans[i];
    }
    cout << "\n";
  } else {
    cout << "NO\n";
  }
}
