#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const long double PI = 3.1415926535898;
const long long oo = (1ll << 62) - 1;
const int N = 2e5 + 5;
int n, k;
int p[N], q[N], l[N], ans[N], res[N];
vector<pair<int, int> > v, cnt;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) cin >> q[i];
  for (int i = 1; i <= n; i++) {
    l[p[i]] = i;
  }
  for (int i = 1; i < n; i++) {
    int a = l[q[i]], b = l[q[i + 1]];
    if (a > b) v.push_back(make_pair(b, a));
  }
  sort(v.begin(), v.end());
  cnt.push_back(v.front());
  for (int i = 0; i < v.size(); i++) {
    if (v[i].first <= cnt.back().second) {
      cnt.back().second = max(cnt.back().second, v[i].second);
    } else {
      cnt.push_back(v[i]);
    }
  }
  int j = 0;
  ans[1] = 1;
  for (int i = 2; i <= n; i++) {
    while (i > cnt[j].second && j < cnt.size()) j++;
    if (i > cnt[j].first && i <= cnt[j].second) {
      ans[i] = ans[i - 1];
    } else
      ans[i] = ans[i - 1] + 1;
  }
  for (int i = 1; i <= n; i++) {
    res[p[i]] = min(k, ans[i]);
  }
  if (ans[n] < k) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << '\n';
  for (int i = 1; i <= n; i++) {
    cout << char(res[i] - 1 + 'a');
  }
}
