#include <bits/stdc++.h>
using namespace std;
long long n;
long long k;
vector<long long> v[200001];
vector<long long> rv[200001];
stack<long long> second;
bool visited[200001];
bool visit[200001];
vector<vector<long long>> comp;
void rdfs(long long node, vector<long long>& temp) {
  temp.push_back(node);
  visit[node] = true;
  for (auto c : rv[node]) {
    if (!visit[c]) {
      rdfs(c, temp);
    }
  }
}
void order() {
  while (!second.empty()) {
    long long node = second.top();
    second.pop();
    if (visit[node]) continue;
    vector<long long> temp;
    rdfs(node, temp);
    comp.push_back(temp);
  }
}
void dfs(long long node) {
  visited[node] = true;
  for (auto c : v[node]) {
    if (!visited[c]) dfs(c);
  }
  second.push(node);
}
void solve() {
  cin >> n >> k;
  long long a[n], b[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    b[i]--;
  }
  for (long long i = 1; i < n; i++) {
    v[a[i - 1]].push_back(a[i]);
    rv[a[i]].push_back(a[i - 1]);
    v[b[i - 1]].push_back(b[i]);
    rv[b[i]].push_back(b[i - 1]);
  }
  for (long long i = 0; i < n; i++) {
    if (!visited[i]) dfs(i);
  }
  order();
  if ((long long)(comp).size() < k) {
    cout << "NO"
         << "\n";
  } else {
    cout << "YES"
         << "\n";
    long long start = -1;
    char ans[n];
    for (auto c : comp) {
      start++;
      start = min(start, (long long)25);
      for (auto d : c) {
        ans[d] = char(start + 'a');
      }
    }
    for (long long i = 0; i < n; i++) cout << ans[i];
    cout << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
