#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
long long fn(long long x, long long rn[]) {
  if (x == rn[x])
    return x;
  else
    return rn[x] = fn(rn[x], rn);
}
bool un(long long x, long long y, long long rn[], long long sz[]) {
  x = fn(x, rn);
  y = fn(y, rn);
  if (x == y) return false;
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  rn[y] = x;
  return true;
}
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long MOD = 998244353;
long long mod = 1000000007;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long inv(long long val, long long MODx = MOD) {
  return power(val, MODx - 2, MODx);
}
vector<long long> fac, ifac;
void preFac(long long sz) {
  fac.resize(sz + 1), ifac.resize(sz + 1);
  fac[0] = 1;
  for (int i = 1; i <= sz; i++) {
    fac[i] = (i * fac[i - 1]) % MOD;
  }
  ifac[sz] = inv(fac[sz]);
  for (int i = sz - 1; i >= 0; i--) {
    ifac[i] = ((i + 1) * ifac[i + 1]) % MOD;
  }
}
long long nCr(long long N, long long R) {
  if (R <= N and R >= 0) {
    return ((fac[N] * ifac[R]) % MOD * ifac[N - R]) % MOD;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  map<long long, long long> pos;
  long long p[n + 1], q[n + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> q[i];
    pos[q[i]] = i;
  }
  long long pt = 1;
  long long pt_cons = 1;
  vector<vector<long long>> comp;
  vector<long long> vec;
  while (pt <= n) {
    vec.push_back(p[pt]);
    pt_cons = max(pt_cons, pos[p[pt]]);
    if (pt == pt_cons) {
      comp.push_back(vec);
      vec.clear();
      pt_cons = 1;
    }
    pt++;
  }
  if (!vec.empty()) {
    comp.push_back(vec);
  }
  if (comp.size() < k) {
    cout << "NO";
    return 0;
  }
  string ans(n + 1, '*');
  char x = 'a';
  for (auto u : comp) {
    for (auto v : u) {
      ans[v] = x;
    }
    x++;
    if (x == ('z' + 1)) {
      x = 'z';
    }
  }
  cout << "YES\n";
  for (long long i = 1; i <= n; i++) {
    cout << ans[i];
  }
}
