#include <bits/stdc++.h>   using namespace std;   constexpr int SIZE = (int)1e6;   int n, k, from, to;   vector<int> g[SIZE], h[SIZE];   vector<int> ord;   vector<bool> check;   string ans;   int component[SIZE];   int comp;   void dfs1(int v) {     check[v] = true;     for (int i : g[v]) {       if (!check[i]) {         dfs1(i);       }     }     ord.push_back(v);   }   void dfs2(int v) {     check[v] = true;     component[v] = comp;     for (int i : h[v]) {       if (!check[i]) {         dfs2(i);       }     }   }   int main() {     cin >> n >> k;     for (int j = 0; j < 2; j++) {       cin >> from;       from--;       for (int i = 1; i < n; i++) {         cin >> to;         to--;         g[from].push_back(to);         h[to].push_back(from);         from = to;       }     }     check.resize(n, false);     for (int i = 0; i < n; i++) {       if (!check[i]) {         dfs1(i);       }     }     for (int i = 0; i < n; i++) {       check[i] = false;     }     for (int i = ord.size() - 1; i >= 0; i--) {       if (!check[ord[i]]) {         dfs2(ord[i]);         comp++;       }     }     if (comp < k) {       cout <<  NO ;       return 0;     }     ans.resize(n);     cout <<  YES  << endl;     for (int i = 0; i < ans.size(); i++) {       if (k - 1 < component[i]) {         ans[i] = char( a  + k - 1);       } else {         ans[i] = char( a  + component[i]);       }     }     cout << ans;     return 0;   }   