#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const int MOD = 1000000007;
char out[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> p(n), q(n), rnk(n), corr(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
    rnk[p[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
    q[i]--;
    corr[i] = rnk[q[i]];
  }
  vector<pair<int, int> > ivs;
  for (int i = 0; i < n - 1; i++) {
    if (corr[i] > corr[i + 1]) ivs.push_back({corr[i + 1], corr[i]});
  }
  sort(ivs.begin(), ivs.end());
  int cend = -1, ci = 0;
  char c = 'a';
  int i = 0;
  for (; i < n; i++) {
    if (c == 'a' + k - 1) break;
    if (ci < ivs.size() && ivs[ci].first <= i) {
      cend = max(cend, ivs[ci].second);
      ci++;
    }
    out[p[i]] = c;
    if (cend <= i && i < n - 1) c++;
  }
  for (; i < n; i++) out[p[i]] = c;
  if (c < 'a' + k - 1) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    for (int j = 0; j < n; j++) cout << out[j];
    cout << "\n";
  }
  return 0;
}
