#include <bits/stdc++.h>
using namespace std;
const unsigned long long hash1 = 201326611;
const double eps = 1e-8;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int N = 4e5 + 10;
const int M = 12;
const int dif = 26;
const double PI = acos(-1.0);
inline void Mod(long long& x) {
  if (x >= mod) x -= mod;
}
void BinaryBitset(int n) { cout << bitset<sizeof(int) * 4>(n) << endl; }
int n, k;
int a[N], b[N], f[N];
char s[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  int cnt = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    f[a[i]]++;
    if (f[a[i]]) cnt++;
    if (f[b[i]]) cnt--;
    f[b[i]]--;
    s[a[i]] = (char)(ans + 'a');
    if (cnt == 0 && i != n) ans = min(ans + 1, k - 1);
  }
  if (ans == k - 1) {
    puts("YES");
    for (int i = 1; i <= n; i++) cout << s[i];
  } else
    puts("NO");
}
