#include <bits/stdc++.h>
using namespace std;
const long long logN = 20;
const long long M = 1000000007;
const long long INF = 1e12;
const long long N = 200005;
long long A[N], B[N];
set<long long> P, Q;
vector<long long> pos;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> A[i];
  for (long long i = 0; i < n; i++) cin >> B[i];
  for (long long i = 0; i < n; i++) {
    if (Q.count(A[i])) {
      Q.erase(A[i]);
    } else {
      P.insert(A[i]);
    }
    if (P.count(B[i])) {
      P.erase(B[i]);
    } else {
      Q.insert(B[i]);
    }
    if (P.empty() and Q.empty()) {
      pos.push_back(i);
    }
  }
  if (pos.size() < m) {
    cout << "NO"
         << "\n";
    return 0;
  }
  cout << "YES"
       << "\n";
  string s(n, ' ');
  long long l = 0;
  for (long long i = 0; i < pos.size(); i++) {
    long long r = pos[i];
    for (long long j = l; j < r + 1; j++) s[A[j] - 1] = ('a' + min(i, 25LL));
    l = r + 1;
  }
  cout << s << "\n";
  return 0;
}
