#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "<" << p.first << "," << p.second << ">";
}
template <typename... T>
ostream& operator<<(ostream& os, const vector<T...>& c) {
  if (c.empty()) return os << "{ }";
  auto ite = c.begin();
  os << "{ " << *ite;
  while (++ite != c.end()) os << ", " << *ite;
  return os << " }";
}
template <typename... T>
ostream& operator<<(ostream& os, const deque<T...>& c) {
  if (c.empty()) return os << "{ }";
  auto ite = c.begin();
  os << "{ " << *ite;
  while (++ite != c.end()) os << ", " << *ite;
  return os << " }";
}
template <typename... T>
ostream& operator<<(ostream& os, const list<T...>& c) {
  if (c.empty()) return os << "{ }";
  auto ite = c.begin();
  os << "{ " << *ite;
  while (++ite != c.end()) os << ", " << *ite;
  return os << " }";
}
template <typename... T>
ostream& operator<<(ostream& os, const set<T...>& c) {
  if (c.empty()) return os << "{ }";
  auto ite = c.begin();
  os << "{ " << *ite;
  while (++ite != c.end()) os << ", " << *ite;
  return os << " }";
}
template <typename... T>
ostream& operator<<(ostream& os, const map<T...>& c) {
  if (c.empty()) return os << "{ }";
  auto ite = c.begin();
  os << "{ " << *ite;
  while (++ite != c.end()) os << ", " << *ite;
  return os << " }";
}
template <typename... T>
ostream& operator<<(ostream& os, const multiset<T...>& c) {
  if (c.empty()) return os << "{ }";
  auto ite = c.begin();
  os << "{ " << *ite;
  while (++ite != c.end()) os << ", " << *ite;
  return os << " }";
}
template <typename... T>
ostream& operator<<(ostream& os, const multimap<T...>& c) {
  if (c.empty()) return os << "{ }";
  auto ite = c.begin();
  os << "{ " << *ite;
  while (++ite != c.end()) os << ", " << *ite;
  return os << " }";
}
void dbg() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg(Head h, Tail... t) {
  cerr << " " << h;
  dbg(t...);
}
constexpr const int maxn = 1 << 20;
int dfn[maxn], low_link[maxn], scc[maxn], dfs_clock, scc_size, deg[maxn];
char res[maxn], col[maxn];
vector<int> adj[maxn], dag[maxn];
stack<int> stk;
void dfs(int u) {
  dfn[u] = low_link[u] = ++dfs_clock;
  stk.push(u);
  for (int v : adj[u]) {
    if (!dfn[v]) {
      dfs(v);
      low_link[u] = min(low_link[u], low_link[v]);
    } else if (!scc[v]) {
      low_link[u] = min(low_link[u], dfn[v]);
    }
  }
  if (low_link[u] == dfn[u]) {
    ++scc_size;
    while (true) {
      int top = stk.top();
      stk.pop();
      scc[top] = scc_size;
      if (top == u) break;
    }
  }
}
void SCC(int n) {
  memset(dfn + 1, 0, n << 2);
  memset(scc + 1, 0, n << 2);
  dfs_clock = scc_size = 0;
  for (int u = 1; u <= n; ++u)
    if (!dfn[u]) dfs(u);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> p(n), q(n);
  for (int& _p : p) cin >> _p;
  for (int& _q : q) cin >> _q;
  for (int i = 1; i != n; ++i) adj[p[i - 1]].push_back(p[i]);
  for (int i = 1; i != n; ++i) adj[q[i - 1]].push_back(q[i]);
  SCC(n);
  for (int u = 1; u <= n; ++u) 0;
  if (scc_size < k) return cout << "NO" << endl, 0;
  cout << "YES" << endl;
  for (int u = 1; u <= n; ++u)
    for (int v : adj[u])
      if (scc[u] != scc[v]) dag[scc[u]].push_back(scc[v]);
  for (int u = 1; u <= n; ++u) adj[u].resize(0);
  for (int u = 1; u <= scc_size; ++u)
    for (int v : dag[u]) adj[v].push_back(u);
  for (int u = 1; u <= scc_size; ++u) 0;
  vector<int> topo;
  for (int u = 1; u <= scc_size; ++u)
    if (!(deg[u] = adj[u].size())) topo.push_back(u);
  for (int i = 0; i != scc_size; ++i)
    for (int u : dag[topo[i]])
      if (!--deg[u]) topo.push_back(u);
  for (int i = 0; i != scc_size; ++i) col[topo[i]] = char('a' + min(25, i));
  for (int i = 1; i <= n; ++i) res[i] = col[scc[i]];
  cout << res + 1 << endl;
}
