#include <bits/stdc++.h>
using namespace std;
struct dsu {
  int n;
  vector<int> par;
  vector<int> sz;
  dsu(int _n) : n(_n), par(n, -1), sz(n, 1) {}
  int getpar(int a) { return par[a] == -1 ? a : (par[a] = getpar(par[a])); }
  bool merge(int a, int b) {
    a = getpar(a);
    b = getpar(b);
    if (a == b) return false;
    n--;
    if (sz[a] < sz[b]) swap(a, b);
    par[b] = a;
    sz[a] += sz[b];
    return true;
  }
};
const int MAXN = 3e5;
int N;
int K;
int P[MAXN];
int Q[MAXN];
int Pinv[MAXN];
int acc[MAXN];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    P[i]--;
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
    Q[i]--;
  }
  for (int i = 0; i < N; i++) {
    Pinv[P[i]] = i;
  }
  for (int i = 0; i + 1 < N; i++) {
    int a = Pinv[Q[i]];
    int b = Pinv[Q[i + 1]];
    if (a > b) {
      acc[b + 1]++;
      acc[a + 1]--;
    }
  }
  string ans(N, 0);
  char cur = 'a' - 1;
  for (int i = 0, covered = 0; i < N; i++) {
    covered += acc[i];
    if (cur != 'z' && (i == 0 || !covered)) {
      cur++;
    }
    ans[P[i]] = cur;
  }
  if (int(cur - 'a' + 1) < K) {
    cout << "NO" << '\n';
  } else {
    cout << "YES" << '\n';
    cout << ans << '\n';
  }
  return 0;
}
