#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
bool isPrime(long long a) {
  long long i;
  for (i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      return 0;
    }
  }
  return (a != 1);
}
bool isPalindrom(const string &s, int l, int r) {
  for (int i = 0; i < (r - l + 1) / 2; i++) {
    if (s[l + i] != s[r - i]) {
      return 0;
    }
  }
  return 1;
}
template <class type1>
type1 gcd(type1 a, type1 b) {
  type1 t;
  while (b) {
    t = b;
    b = a % b;
    a = t;
  }
  return a;
}
long long positiveMod(long long v, long long md) {
  v = v % md;
  if (v < 0) {
    v += md;
  }
  return v;
}
int inp1[200005];
int inp2[200005];
int dat1[200005], pos1[200005];
int dat2[200005], pos2[200005];
vector<pair<int, int> > inf, resInf;
string res;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k, i, j, a, b;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> dat1[i];
    inp1[i] = dat1[i];
    pos1[dat1[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    cin >> dat2[i];
    inp2[i] = dat2[i];
    pos2[dat2[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    dat2[pos2[dat1[i]]] = i;
    dat1[i] = i;
  }
  for (i = 1; i <= n; i++) {
    inf.push_back({dat1[i], dat2[i]});
  }
  a = 1;
  b = 1;
  sort(inf.begin(), inf.end());
  for (i = 0; i < inf.size(); i++) {
    if (b < inf[i].first) {
      resInf.push_back({a, b});
      a = inf[i].first;
      b = inf[i].second;
    } else {
      b = max(b, inf[i].second);
    }
  }
  resInf.push_back({a, b});
  res.resize(n);
  if (resInf.size() < k) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (i = 0; i < resInf.size(); i++) {
    a = min(i, k - 1);
    for (j = resInf[i].first; j <= resInf[i].second; j++) {
      res[inp1[dat1[j]] - 1] = 'a' + a;
    }
  }
  cout << res << "\n";
  return 0;
}
