#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
const int oo = 2e9;
int n, k, p[2][N], ans[N];
set<int> st[2];
queue<int> q;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < n; ++j) {
      cin >> p[i][j];
      --p[i][j];
    }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 2; ++j) {
      int v = (j + 1) % 2;
      if (st[v].find(p[j][i]) == st[v].end())
        st[j].insert(p[j][i]);
      else
        st[v].erase(p[j][i]);
    }
    if (st[0].empty() && st[1].empty()) q.push(i);
  }
  if (q.size() < k) {
    cout << "NO";
    return 0;
  }
  cout << "YES"
       << "\n";
  int l = 0, let = 0;
  while (!q.empty()) {
    int r = q.front();
    q.pop();
    for (int i = l; i <= r; ++i) ans[p[0][i]] = let;
    l = r + 1;
    let = min(let + 1, 25);
  }
  for (int i = 0; i < n; ++i) cout << char(ans[i] + 97);
}
