#include <bits/stdc++.h>
using namespace std;
const long long int logx = 30;
const long long int N = 4e5 + 5;
const long long int M = 1e3 + 5;
const long long int mod = 1e9 + 7;
const long long int INF = 1e18 + 5;
const double PI = 3.14159265358979323846;
inline long long int mul(long long int a, long long int b, long long int p) {
  return (a * 1ll * b) % p;
}
inline long long int sub(long long int a, long long int b, long long int p) {
  long long int c = a - b;
  if (c < 0) c += p;
  return c;
}
inline long long int add(long long int a, long long int b, long long int p) {
  long long int c = a + b;
  if (c > p) c -= p;
  return c;
}
template <typename T>
T power(T x, T y, long long int m) {
  T ans = 1;
  while (y > 0) {
    if (y & 1LL) ans = (ans * x) % m;
    y >>= 1ll;
    x = (x * x) % m;
  }
  return ans % m;
}
char ans[N];
stack<long long int> order;
vector<long long int> g[N], nog[N], comp[N];
long long int n, k, p[N], q[N], vis[N];
void SCMP(long long int cur) {
  vis[cur] = 1;
  for (auto child : g[cur]) {
    if (vis[child]) {
      continue;
    }
    SCMP(child);
  }
  order.push(cur);
}
void NCMP(long long int cur, long long int cnt) {
  vis[cur] = 1;
  comp[cnt].push_back(cur);
  for (auto child : nog[cur]) {
    if (vis[child]) {
      continue;
    }
    NCMP(child, cnt);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int cnt = 0;
  cin >> n >> k;
  for (long long int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (long long int i = 1; i <= n; i++) {
    cin >> q[i];
  }
  for (long long int i = 1; i < n; i++) {
    g[p[i]].push_back(p[i + 1]);
    nog[p[i + 1]].push_back(p[i]);
  }
  for (long long int i = 1; i < n; i++) {
    g[q[i]].push_back(q[i + 1]);
    nog[q[i + 1]].push_back(q[i]);
  }
  for (long long int i = 1; i <= n; i++) {
    if (vis[i]) {
      continue;
    }
    SCMP(i);
  }
  for (long long int i = 1; i < N; i++) {
    vis[i] = 0;
  }
  while (order.size()) {
    long long int cur = order.top();
    if (!vis[cur]) {
      NCMP(cur, cnt++);
    }
    order.pop();
  }
  char cur = 'a';
  if (cnt < k) {
    cout << "NO" << endl;
    exit(0);
  }
  for (long long int i = 0; i < cnt; i++) {
    for (auto j : comp[i]) {
      ans[j] = cur;
    }
    if (cur == 'z') {
      continue;
    }
    cur++;
  }
  cout << "YES" << endl;
  for (long long int i = 1; i <= n; i++) {
    cout << ans[i];
  }
}
