#include <bits/stdc++.h>
using namespace std;
void doRoutine() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  srand(322179);
}
signed main() {
  doRoutine();
  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];
  }
  vector<int> pos_in_p(n);
  for (int i = 0; i < n; ++i) {
    pos_in_p[p[i]] = i;
  }
  vector<int> trans(n);
  for (int i = 0; i + 1 < n; ++i) {
    int from = pos_in_p[q[i]], to = pos_in_p[q[i + 1]];
    if (from > to) {
      ++trans[to];
      --trans[from];
    }
  }
  for (int i = 1; i < n - 1; ++i) {
    trans[i] += trans[i - 1];
  }
  vector<int> color(n, -1);
  int cur_color = 0;
  for (int i = 0; i < n;) {
    int j = i + 1;
    color[i] = cur_color;
    while (j < n && trans[j - 1]) {
      color[j] = cur_color;
      ++j;
    }
    i = j;
    ++cur_color;
  }
  if (cur_color >= k) {
    for (int i = 0; i < n; ++i) {
      if (color[i] >= k - 1) {
        color[i] = k - 1;
      }
    }
    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
      ans[p[i]] = color[i];
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; ++i) {
      cout << (char)('a' + ans[i]);
    }
    cout << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
