#include <bits/stdc++.h>
using namespace std;
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline long long mnz(long long& a, long long b) { return a = (a > b ? b : a); }
inline long long mxz(long long& a, long long b) { return a = (a < b ? b : a); }
inline string toString(long long n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
double const eps = 1e-6;
long long const Base = 1e9 + 7, oo = 1e17, MAXN = 2e5;
long long A[MAXN + 5], B[MAXN + 5], P[MAXN + 5], R[MAXN + 5];
vector<long long> L[MAXN + 5];
long long Solves() {
  long long n, m, k, cnt = 0, ans = 0, x, y, q, c, sum = 0, v, t;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> A[i], P[A[i]] = i, R[i] = i;
  for (long long i = 1; i <= n; i++) cin >> B[i];
  for (long long i = n - 1; i >= 1; i--)
    if (P[B[i]] > P[B[i + 1]]) mxz(R[P[B[i + 1]]], P[B[i]]);
  c = 0;
  t = 0;
  vector<long long> vec;
  for (long long i = 1; i <= n; i++) {
    mxz(t, R[i]);
    vec.push_back(A[i]);
    if (t == i) {
      cnt++;
      while ((long long)vec.size())
        L[cnt].push_back(vec.back()), vec.pop_back();
    }
  }
  if (cnt < k) return cout << "NO" << endl, 0;
  string s = "";
  for (long long i = 1; i <= n; i++) s.push_back('a');
  for (long long i = 1; i <= cnt; i++) {
    for (long long j = 0; j < L[i].size(); j++)
      s[L[i][j] - 1] += min('z' - 'a', (int)i - 1);
  }
  cout << "YES" << endl;
  cout << s << endl;
  return 0;
}
int main() {
  long long JUDGE_ONLINE = 1;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  for (long long T = 1; T <= test; T++) {
    Solves();
  }
  if (!JUDGE_ONLINE)
    cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
