#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj, rev, scc;
vector<bool> visited;
vector<int> post_order, component;
void dfs1(int node) {
  visited[node] = true;
  for (auto u : adj[node]) {
    if (!visited[u]) dfs1(u);
  }
  post_order.push_back(node);
}
void dfs2(int node) {
  visited[node] = true;
  component.push_back(node);
  for (auto u : rev[node]) {
    if (!visited[u]) dfs2(u);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
    q[i]--;
  }
  adj.resize(n);
  rev.resize(n);
  visited.resize(n);
  for (int i = 0; i < n - 1; i++) {
    adj[p[i]].push_back(p[i + 1]);
    adj[q[i]].push_back(q[i + 1]);
    rev[p[i + 1]].push_back(p[i]);
    rev[q[i + 1]].push_back(q[i]);
  }
  dfs1(p[0]);
  reverse(post_order.begin(), post_order.end());
  for (int i = 0; i < n; i++) visited[i] = 0;
  for (auto node : post_order) {
    if (!visited[node]) {
      component.clear();
      dfs2(node);
      scc.push_back(component);
    }
  }
  string ans;
  ans.resize(n);
  char c = 'a';
  int m = 0;
  for (const auto& component : scc) {
    for (auto i : component) ans[i] = c;
    if (c < 'z') c++;
    m++;
  }
  if (m >= k) {
    cout << "YES" << endl;
    cout << ans << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
