#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535897932384626433832795;
const int inf = 1e9;
const long long inf2 = 1e18;
const int mod = 1e9 + 7;
void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n), pos(n, 0), q(n), r(n, 0), l(n, 0);
  iota(r.begin(), r.end(), 0);
  iota(l.begin(), l.end(), 0);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    p[i]--;
    pos[p[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    cin >> q[i];
    q[i]--;
  }
  for (int i = 0; i < n - 1; i++) {
    if (pos[q[i]] > pos[q[i + 1]]) {
      l[pos[q[i]]] = pos[q[i + 1]];
    }
  }
  int x = 0, y = 0, curl = n;
  for (int i = n - 1; i >= 0; i--) {
    if (curl > i) {
      y = 0;
    }
    curl = min(curl, l[i]);
    y = max(y, i);
    r[i] = max(r[i], y);
  }
  vector<int> ans(n, 0);
  k--;
  int lst = 0;
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j <= r[i]) {
      ans[p[j]] = x;
      lst = x;
      j++;
    }
    i = j - 1;
    if (x < k) x++;
  }
  if (lst < k) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) {
    cout << (char)(ans[i] + 'a');
  }
  return;
}
int main() {
  boost();
  int tc = 1;
  while (tc--) solve();
  return 0;
}
