#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <chrono>
#include <queue>
#include <random>
#include <immintrin.h>
#include <unordered_set>

int32_t* dsu_parents;
int32_t* dsu_right;

int32_t find_parent(int32_t vertex) {
    if(dsu_parents[vertex] == vertex)
	return vertex;
    return dsu_parents[vertex] = find_parent(dsu_parents[vertex]);
}

bool join(int32_t v1, int32_t v2) {
    int32_t root1 = find_parent(v1);
    int32_t root2 = find_parent(v2);
    if(root1 == root2)
	return false;
    dsu_parents[root1] = root2;
    dsu_right[root2] = std::max(dsu_right[root1], dsu_right[root2]);
    return true;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);

    int32_t n, k;
    std::cin >> n >> k;

    int32_t* arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr1[i];
	arr1[i]--;
    }

    int32_t* arr2 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr2[i];
	arr2[i]--;
    }

    int32_t* r_arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++)
	r_arr1[arr1[i]] = i;

    dsu_parents = new int32_t[n];
    dsu_right = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++) {
	dsu_parents[i] = i;
	dsu_right[i] = i;
    }

    int32_t* next = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++) {
	next[i] = i + 1;
    }

    int32_t left = n;
    for(int32_t i = 0 ; i < n - 1; i++) {
	if(r_arr1[arr2[i]] < r_arr1[arr2[i + 1]])
	    continue;
	int32_t cur = r_arr1[arr2[i + 1]];
	while(cur != dsu_right[find_parent(r_arr1[arr2[i]])] + 1) {
	    if(join(cur, r_arr1[arr2[i + 1]]))
		left--;
	    cur = dsu_right[find_parent(cur)] + 1;
	}
	if(join(r_arr1[arr2[i]], r_arr1[arr2[i + 1]]))
	    left--;
    }

    if(k > left) {
	std::cout << "NO";
	return 0;
    }
    std::cout << "YES" << "\n";
    std::string answer(n, ' ');

    std::map<int32_t, char> per_component;
    char new_char = 'a';
    for(int32_t i = 0 ;  i < n  ; i++) {
	int32_t ind = r_arr1[i];
	if (per_component.find(find_parent(ind)) == per_component.end()) {
	    per_component[find_parent(ind)] = new_char;
	    if(new_char != 'a' + k - 1)
		new_char++;
	}
	answer[ind] = per_component[find_parent(ind)];
    }
    std::cout << answer;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <chrono>
#include <queue>
#include <random>
#include <immintrin.h>
#include <unordered_set>

int32_t* dsu_parents;
int32_t* dsu_right;

int32_t find_parent(int32_t vertex) {
    if(dsu_parents[vertex] == vertex)
	return vertex;
    return dsu_parents[vertex] = find_parent(dsu_parents[vertex]);
}

bool join(int32_t v1, int32_t v2) {
    int32_t root1 = find_parent(v1);
    int32_t root2 = find_parent(v2);
    if(root1 == root2)
	return false;
    dsu_parents[root1] = root2;
    dsu_right[root2] = std::max(dsu_right[root1], dsu_right[root2]);
    return true;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);

    int32_t n, k;
    std::cin >> n >> k;

    int32_t* arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr1[i];
	arr1[i]--;
    }

    int32_t* arr2 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr2[i];
	arr2[i]--;
    }

    int32_t* r_arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++)
	r_arr1[arr1[i]] = i;

    dsu_parents = new int32_t[n];
    dsu_right = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++) {
	dsu_parents[i] = i;
	dsu_right[i] = i;
    }

    int32_t* next = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++) {
	next[i] = i + 1;
    }

    int32_t left = n;
    for(int32_t i = 0 ; i < n - 1; i++) {
	if(r_arr1[arr2[i]] < r_arr1[arr2[i + 1]])
	    continue;
	int32_t cur = r_arr1[arr2[i + 1]];
	while(cur != dsu_right[find_parent(r_arr1[arr2[i]])] + 1) {
	    if(join(cur, r_arr1[arr2[i + 1]]))
		left--;
	    cur = dsu_right[find_parent(cur)] + 1;
	}
	if(join(r_arr1[arr2[i]], r_arr1[arr2[i + 1]]))
	    left--;
    }

    if(k > left) {
	std::cout << "NO";
	return 0;
    }
    std::cout << "YES" << "\n";
    std::string answer(n, ' ');

    std::map<int32_t, char> per_component;
    char new_char = 'a';
    for(int32_t i = 0 ;  i < n  ; i++) {
	int32_t ind = r_arr1[i];
	if (per_component.find(find_parent(ind)) == per_component.end()) {
	    per_component[find_parent(ind)] = new_char;
	    if(new_char != 'a' + k - 1)
		new_char++;
	}
    }
    for(int32_t i = 0 ; i < n ;i++)
	answer[arr1[i]] = per_component[find_parent(i)];
    std::cout << answer;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <chrono>
#include <queue>
#include <random>
#include <immintrin.h>
#include <unordered_set>

int32_t* dsu_parents;

int32_t find_parent(int32_t vertex) {
    if(dsu_parents[vertex] == vertex)
	return vertex;
    return dsu_parents[vertex] = find_parent(dsu_parents[vertex]);
}

bool join(int32_t v1, int32_t v2) {
    int32_t root1 = find_parent(v1);
    int32_t root2 = find_parent(v2);
    if(root1 == root2)
	return false;
    dsu_parents[root1] = root2;
    return true;
}

int main() {
    int32_t n, k;
    std::cin >> n >> k;

    int32_t* arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr1[i];
	arr1[i]--;
    }

    int32_t* arr2 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr2[i];
	arr2[i]--;
    }

    int32_t* r_arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++)
	r_arr1[arr1[i]] = i;

    dsu_parents = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++)
	dsu_parents[i] = i;

    int32_t* next = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++) {
	next[i] = i + 1;
    }

    int32_t left = n;
    for(int32_t i = 0 ; i < n - 1; i++) {
	if(r_arr1[arr2[i]] < r_arr1[arr2[i + 1]])
	    continue;
	int32_t cur = r_arr1[arr2[i + 1]];
	while(cur != r_arr1[arr2[i]]) {
	    if(join(cur, r_arr1[arr2[i + 1]]))
		left--;
	    cur = next[cur];
	}
	if(join(r_arr1[arr2[i]], r_arr1[arr2[i + 1]]))
	    left--;

	next[r_arr1[arr2[i + 1]] = r_arr1[arr2[i]]] + 1;
    }

    if(k > left) {
	std::cout << "NO";
	return 0;
    }
    std::cout << "YES" << "\n";
    std::string answer(n, ' ');

    std::map<int32_t, char> per_component;
    char new_char = 'a';
    for(int32_t i = 0 ;  i < n  ; i++) {
	if (per_component.find(dsu_parents[i]) == per_component.end()) {
	    per_component[dsu_parents[i]] = new_char;
	    if(new_char != 'a' + k - 1)
		new_char++;
	}
	answer[i] = per_component[dsu_parents[i]];
    }
    std::cout << answer;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <chrono>
#include <queue>
#include <random>
#include <immintrin.h>
#include <unordered_set>

int32_t* dsu_parents;

int32_t find_parent(int32_t vertex) {
    if(dsu_parents[vertex] == vertex)
	return vertex;
    return dsu_parents[vertex] = find_parent(dsu_parents[vertex]);
}

void join(int32_t v1, int32_t v2) {
    int32_t root1 = find_parent(v1);
    int32_t root2 = find_parent(v2);
    if(root1 == root2)
	return;
    dsu_parents[root1] = root2;
}

int main() {
    int32_t n, k;
    std::cin >> n >> k;

    int32_t* arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr1[i];
	arr1[i]--;
    }

    int32_t* arr2 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr2[i];
	arr2[i]--;
    }

    int32_t* r_arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++)
	r_arr1[arr1[i]] = i;

    dsu_parents = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++)
	dsu_parents[i] = i;

    for(int32_t i = 0 ; i < n - 1; i++) {
	if(r_arr1[arr2[i]] < r_arr1[arr2[i + 1]])
	    continue;
	int32_t cur = arr2[i + 1];
	while(cur != arr2[i]) {
	    join(r_arr1[cur], r_arr1[arr2[i]]);
	    cur = arr1[r_arr1[arr1[cur]] + 1];
	}
    }

    if(k > n) {
	std::cout << "NO";
	return 0;
    }
    std::cout << "YES" << "\n";
    std::string answer(n, ' ');

    std::map<int32_t, char> per_component;
    char new_char = 'a';
    for(int32_t i = 0 ;  i < n  ; i++) {
	if (per_component.find(dsu_parents[i]) == per_component.end()) {
	    per_component[dsu_parents[i]] = new_char;
	    if(new_char != 'a' + k - 1)
		new_char++;
	}
	answer[i] = per_component[dsu_parents[i]];
    }
    std::cout << answer;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <chrono>
#include <queue>
#include <random>
#include <immintrin.h>
#include <unordered_set>

int32_t* dsu_parents;
int32_t* dsu_right;

int32_t find_parent(int32_t vertex) {
    if(dsu_parents[vertex] == vertex)
	return vertex;
    return dsu_parents[vertex] = find_parent(dsu_parents[vertex]);
}

bool join(int32_t v1, int32_t v2) {
    int32_t root1 = find_parent(v1);
    int32_t root2 = find_parent(v2);
    if(root1 == root2)
	return false;
    dsu_parents[root1] = root2;
    dsu_right[root2] = std::max(dsu_right[root1], dsu_right[root2]);
    return true;
}

int main() {
    int32_t n, k;
    std::cin >> n >> k;

    int32_t* arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr1[i];
	arr1[i]--;
    }

    int32_t* arr2 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr2[i];
	arr2[i]--;
    }

    int32_t* r_arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++)
	r_arr1[arr1[i]] = i;

    dsu_parents = new int32_t[n];
    dsu_right = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++) {
	dsu_parents[i] = i;
	dsu_right[i] = i;
    }

    int32_t* next = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++) {
	next[i] = i + 1;
    }

    int32_t left = n;
    for(int32_t i = 0 ; i < n - 1; i++) {
	if(r_arr1[arr2[i]] < r_arr1[arr2[i + 1]])
	    continue;
	int32_t cur = r_arr1[arr2[i + 1]];
	while(cur != r_arr1[arr2[i]]) {
	    if(join(cur, r_arr1[arr2[i + 1]]))
		left--;
	    cur = dsu_right[find_parent(cur)] + 1;
	}
	if(join(r_arr1[arr2[i]], r_arr1[arr2[i + 1]]))
	    left--;
    }

    if(k > left) {
	std::cout << "NO";
	return 0;
    }
    std::cout << "YES" << "\n";
    std::string answer(n, ' ');

    std::map<int32_t, char> per_component;
    char new_char = 'a';
    for(int32_t i = 0 ;  i < n  ; i++) {
	if (per_component.find(find_parent(i)) == per_component.end()) {
	    per_component[find_parent(i)] = new_char;
	    if(new_char != 'a' + k - 1)
		new_char++;
	}
	answer[i] = per_component[find_parent(i)];
    }
    std::cout << answer;
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <chrono>
#include <queue>
#include <random>
#include <immintrin.h>
#include <unordered_set>

int32_t* dsu_parents;

int32_t find_parent(int32_t vertex) {
    if(dsu_parents[vertex] == vertex)
	return vertex;
    return dsu_parents[vertex] = find_parent(dsu_parents[vertex]);
}

bool join(int32_t v1, int32_t v2) {
    int32_t root1 = find_parent(v1);
    int32_t root2 = find_parent(v2);
    if(root1 == root2)
	return false;
    dsu_parents[root1] = root2;
    return true;
}

int main() {
    int32_t n, k;
    std::cin >> n >> k;

    int32_t* arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr1[i];
	arr1[i]--;
    }

    int32_t* arr2 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ;i++) {
	std::cin >> arr2[i];
	arr2[i]--;
    }

    int32_t* r_arr1 = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++)
	r_arr1[arr1[i]] = i;

    dsu_parents = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++)
	dsu_parents[i] = i;

    int32_t* next = new int32_t[n];
    for(int32_t i = 0 ; i  < n ; i++) {
	next[i] = i + 1;
    }

    int32_t left = n;
    for(int32_t i = 0 ; i < n - 1; i++) {
	if(r_arr1[arr2[i]] < r_arr1[arr2[i + 1]])
	    continue;
	int32_t cur = r_arr1[arr2[i + 1]];
	while(cur != r_arr1[arr2[i]]) {
	    if(join(cur, r_arr1[arr2[i + 1]]))
		left--;
	    cur++;
	}
	if(join(r_arr1[arr2[i]], r_arr1[arr2[i + 1]]))
	    left--;

	next[r_arr1[arr2[i + 1]]] = r_arr1[arr2[i]];
    }

    if(k > left) {
	std::cout << "NO";
	return 0;
    }
    std::cout << "YES" << "\n";
    std::string answer(n, ' ');

    std::map<int32_t, char> per_component;
    char new_char = 'a';
    for(int32_t i = 0 ;  i < n  ; i++) {
	if (per_component.find(dsu_parents[i]) == per_component.end()) {
	    per_component[dsu_parents[i]] = new_char;
	    if(new_char != 'a' + k - 1)
		new_char++;
	}
	answer[i] = per_component[dsu_parents[i]];
    }
    std::cout << answer;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define ld long double
#define ll long long
#define ull unsigned ll
#define TIME 1.0*clock()/CLOCKS_PER_SEC

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 1e5 + 10;
const ll MOD = 1e9 + 7;
const int rx[4] = {-1, 0, 1, 0};
const int ry[4] = {0, 1, 0, -1};
const ld eps = 1e-7;
const double pi = acos(-1.0);
const ll INF = 2e9 + 1000;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p[n], s[n], z[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] --;
        z[i] = p[i];
        s[p[i]] = i;
        p[i] = i;
    }
    int q[n];
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        q[i] --;
        q[i] = s[q[i]];
    }
    vector <int> kol;
    int mx = 0, k2 = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        mx = max(mx, q[i]);
        k2 ++;
        if (mx == i) {
            kol.pb(k2);
            sum += k2;
            k2 = 0;
        }
    }
    for (int i = k; i < kol.size(); i++) kol[k - 1] += kol[i];
    vector <char> ans(n);
    if (kol.size() < k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        int pos = 0;
        for (int i = 0; i < k; i++) {
            for (int j = 0; j < kol[i]; j++) {
                ans[z[pos]] = char('a' + i);
                pos ++;
            }
        }
        for (auto it : ans) cout << it;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define ld long double
#define ll long long
#define ull unsigned ll
#define TIME 1.0*clock()/CLOCKS_PER_SEC

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 1e5 + 10;
const ll MOD = 1e9 + 7;
const int rx[4] = {-1, 0, 1, 0};
const int ry[4] = {0, 1, 0, -1};
const ld eps = 1e-7;
const double pi = acos(-1.0);
const ll INF = 2e9 + 1000;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p[n], s[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] --;
        s[p[i]] = i;
        p[i] = i;
    }
    int q[n];
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        q[i] --;
        q[i] = s[q[i]];
    }
    vector <int> kol;
    int mx = 0, k2 = 0;
    for (int i = 0; i < n; i++) {
        mx = max(mx, q[i]);
        k2 ++;
        if (mx == i) {
            kol.pb(k2);
            k2 = 0;
            mx = -1;
        }
    }
    for (int i = k; i < kol.size(); i++) kol[k - 1] += kol[i];
    vector <char> ans(n);
    if (kol.size() < k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        int pos = 0;
        for (int i = 0; i < kol.size(); i++) {
            for (int j = 0; j < kol[i]; j++) {
                if (q[pos] >= n || q[pos] < 0) {
                    cout << pos << " " << q[pos] << endl;
                    return 0;
                }
                ans[q[pos]] = char('a' + i);
                pos ++;
            }
        }
        for (auto it : ans) cout << it;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define ld long double
#define ll long long
#define ull unsigned ll
#define TIME 1.0*clock()/CLOCKS_PER_SEC

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 1e5 + 10;
const ll MOD = 1e9 + 7;
const int rx[4] = {-1, 0, 1, 0};
const int ry[4] = {0, 1, 0, -1};
const ld eps = 1e-7;
const double pi = acos(-1.0);
const ll INF = 2e9 + 1000;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p[n], s[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] --;
        s[p[i]] = i;
        p[i] = i;
    }
    int q[n];
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        q[i] --;
        q[i] = s[q[i]];
    }
    vector <int> kol;
    int mx = 0, k2 = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        mx = max(mx, q[i]);
        k2 ++;
        if (mx == i) {
            kol.pb(k2);
            sum += k2;
            k2 = 0;
            mx = -1;
        }
    }
    for (int i = k; i < kol.size(); i++) kol[k - 1] += kol[i];
    vector <char> ans(n);
    if (kol.size() < k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        int pos = 0;
        for (int i = 0; i < kol.size(); i++) {
            for (int j = 0; j < kol[i]; j++) {
                if (q[pos] >= n || q[pos] < 0) {
                    cout << kol[0] << " " << sum << " " << pos << " " << q[pos] << endl;
                    return 0;
                }
                ans[q[pos]] = char('a' + i);
                pos ++;
            }
        }
        for (auto it : ans) cout << it;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define ld long double
#define ll long long
#define ull unsigned ll
#define TIME 1.0*clock()/CLOCKS_PER_SEC

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 1e5 + 10;
const ll MOD = 1e9 + 7;
const int rx[4] = {-1, 0, 1, 0};
const int ry[4] = {0, 1, 0, -1};
const ld eps = 1e-7;
const double pi = acos(-1.0);
const ll INF = 2e9 + 1000;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p[n], s[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] --;
        s[p[i]] = i;
        p[i] = i;
    }
    int q[n];
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        q[i] --;
        q[i] = s[q[i]];
    }
    vector <int> kol;
    int mx = 0, k2 = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        mx = max(mx, q[i]);
        k2 ++;
        if (mx == i) {
            kol.pb(k2);
            sum += k2;
            k2 = 0;
            mx = -1;
        }
    }
    for (int i = k; i < kol.size(); i++) kol[k - 1] += kol[i];
    vector <char> ans(n);
    if (kol.size() < k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        int pos = 0;
        for (int i = 0; i < kol.size(); i++) {
            for (int j = 0; j < kol[i]; j++) {
                if (q[pos] >= n || q[pos] < 0) {
                    cout << kol[1] << " " << kol[0] << " " << sum << " " << pos << " " << q[pos] << endl;
                    return 0;
                }
                ans[q[pos]] = char('a' + i);
                pos ++;
            }
        }
        for (auto it : ans) cout << it;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define ld long double
#define ll long long
#define ull unsigned ll
#define TIME 1.0*clock()/CLOCKS_PER_SEC

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 1e5 + 10;
const ll MOD = 1e9 + 7;
const int rx[4] = {-1, 0, 1, 0};
const int ry[4] = {0, 1, 0, -1};
const ld eps = 1e-7;
const double pi = acos(-1.0);
const ll INF = 2e9 + 1000;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p[n], s[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] --;
        s[p[i]] = i;
        p[i] = i;
    }
    int q[n];
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        q[i] --;
        q[i] = s[q[i]];
    }
    vector <int> kol;
    int mx = 0, k2 = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        mx = max(mx, q[i]);
        k2 ++;
        if (mx == i) {
            cout << i << endl;
            kol.pb(k2);
            sum += k2;
            k2 = 0;
        }
    }
    cout << kol.size() << endl;
    for (int i = k; i < kol.size(); i++) kol[k - 1] += kol[i];
    vector <char> ans(n);
    if (kol.size() < k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        int pos = 0;
        for (int i = 0; i < kol.size(); i++) {
            for (int j = 0; j < kol[i]; j++) {
                if (q[pos] >= n || q[pos] < 0) {
                    cout << kol[1] << " " << kol[0] << " " << sum << " " << pos << " " << q[pos] << endl;
                    return 0;
                }
                ans[q[pos]] = char('a' + i);
                pos ++;
            }
        }
        for (auto it : ans) cout << it;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define ld long double
#define ll long long
#define ull unsigned ll
#define TIME 1.0*clock()/CLOCKS_PER_SEC

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 1e5 + 10;
const ll MOD = 1e9 + 7;
const int rx[4] = {-1, 0, 1, 0};
const int ry[4] = {0, 1, 0, -1};
const ld eps = 1e-7;
const double pi = acos(-1.0);
const ll INF = 2e9 + 1000;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p[n], s[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] --;
        s[p[i]] = i;
        p[i] = i;
    }
    int q[n];
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        q[i] --;
        q[i] = s[q[i]];
    }
    vector <int> kol;
    int mx = 0, k2 = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        mx = max(mx, q[i]);
        k2 ++;
        if (mx == i) {
            kol.pb(k2);
            sum += k2;
            k2 = 0;
            mx = -1;
        }
    }
    for (int i = k; i < kol.size(); i++) kol[k - 1] += kol[i];
    vector <char> ans(n);
    if (kol.size() < k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        int pos = 0;
        for (int i = 0; i < kol.size(); i++) {
            for (int j = 0; j < kol[i]; j++) {
                if (q[pos] >= n || q[pos] < 0) {
                    cout << sum << " " << pos << " " << q[pos] << endl;
                    return 0;
                }
                ans[q[pos]] = char('a' + i);
                pos ++;
            }
        }
        for (auto it : ans) cout << it;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define ld long double
#define ll long long
#define ull unsigned ll
#define TIME 1.0*clock()/CLOCKS_PER_SEC

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 1e5 + 10;
const ll MOD = 1e9 + 7;
const int rx[4] = {-1, 0, 1, 0};
const int ry[4] = {0, 1, 0, -1};
const ld eps = 1e-7;
const double pi = acos(-1.0);
const ll INF = 2e9 + 1000;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p[n], s[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] --;
        s[p[i]] = i;
        p[i] = i;
    }
    int q[n];
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        q[i] --;
        q[i] = s[q[i]];
    }
    vector <int> kol;
    int mx = 0, k2 = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        mx = max(mx, q[i]);
        k2 ++;
        if (mx == i) {
            kol.pb(k2);
            sum += k2;
            k2 = 0;
        }
    }
    for (int i = k; i < kol.size(); i++) kol[k - 1] += kol[i];
    vector <char> ans(n);
    if (kol.size() < k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        int pos = 0;
        for (int i = 0; i < k; i++) {
            for (int j = 0; j < kol[i]; j++) {
                ans[q[pos]] = char('a' + i);
                pos ++;
            }
        }
        for (auto it : ans) cout << it;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define ld long double
#define ll long long
#define ull unsigned ll
#define TIME 1.0*clock()/CLOCKS_PER_SEC

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 1e5 + 10;
const ll MOD = 1e9 + 7;
const int rx[4] = {-1, 0, 1, 0};
const int ry[4] = {0, 1, 0, -1};
const ld eps = 1e-7;
const double pi = acos(-1.0);
const ll INF = 2e9 + 1000;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p[n], s[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] --;
        s[p[i]] = i;
        p[i] = i;
    }
    int q[n];
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        q[i] --;
        q[i] = s[q[i]];
    }
    vector <int> kol;
    int mx = 0, k2 = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        mx = max(mx, q[i]);
        k2 ++;
        if (mx == i) {
            kol.pb(k2);
            sum += k2;
            k2 = 0;
            mx = -1;
        }
    }
    for (int i = k; i < kol.size(); i++) kol[k - 1] += kol[i];
    vector <char> ans(n);
    if (kol.size() < k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        int pos = 0;
        for (int i = 0; i < kol.size(); i++) {
            for (int j = 0; j < kol[i]; j++) {
                if (q[pos] >= n || q[pos] < 0) {
                    cout << kol.size() << " " << kol[0] << " " << sum << " " << pos << " " << q[pos] << endl;
                    return 0;
                }
                ans[q[pos]] = char('a' + i);
                pos ++;
            }
        }
        for (auto it : ans) cout << it;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 5e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    ll cord;
    int l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            return l < other.l;
        } else {
            return cord < other.cord;
        }
    }
};

ll curr, last, cnt, n, k;

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        ll l = min(i, inv[perm[i]]), r = max(i, inv[perm[i]]);
        points.pb({l, 0});
        points.pb({r, 1});
    }
    sort(points.begin(), points.end());
    ll izp = 0;
    for(auto p : points) {
        //cout << p.cord << " " << p.l << " " << curr << endl;
        if(p.l == 0) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[perm[i]] = 'a' + cnt;
                }
                if(cnt <= 25) {
                    izp ++;
                }
                //cout << "Ending interval " << last << " " << p.cord << endl;
                if(cnt < 25) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(izp >= k) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 5e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    ll cord;
    int l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            return l < other.l;
        } else {
            return cord < other.cord;
        }
    }
};

ll curr, last, cnt, n, k;

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k; k --;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        ll l = min(i, inv[perm[i]]), r = max(i, inv[perm[i]]);
        points.pb({l, 0});
        points.pb({r, 1});
    }
    sort(points.begin(), points.end());
    for(auto p : points) {
        //cout << p.cord << " " << p.l << " " << curr << endl;
        if(p.l == 0) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[i] = 'a' + cnt;
                }
                //cout << "Ending interval " << last << " " << p.cord << endl;
                if(cnt < 25) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(cnt < 26 && cnt >= k) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 5e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    ll cord;
    int l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            return l < other.l;
        } else {
            return cord < other.cord;
        }
    }
};

ll curr, last, cnt, n, k;

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        ll l = min(i, inv[perm[i]]), r = max(i, inv[perm[i]]);
        points.pb({l, 0});
        points.pb({r, 1});
    }
    sort(points.begin(), points.end());
    ll izp = 0;
    for(auto p : points) {
        //cout << p.cord << " " << p.l << " " << curr << endl;
        if(p.l == 0) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[i] = 'a' + cnt;
                }
                if(cnt <= 25) {
                    izp ++;
                }
                //cout << "Ending interval " << last << " " << p.cord << endl;
                if(cnt < 25) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(izp >= k) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 3e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    ll cord;
    bool l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            if(l) {
                return 1;
            } else if(other.l) {
                return 0;
            }
            return 1;
        } else {
            return cord < other.cord;
        }
    }
};

ll curr, last, cnt, n, k;

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        perm[i] = i + 1;
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        perm[i] = i + 1;
        ll l = min(i, inv[perm[i]]), r = max(i, inv[perm[i]]);
        points.pb({l, true});
        points.pb({r, false});
    }
    sort(points.begin(), points.end());
    for(auto p : points) {
        if(p.l) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[i] = 'a' + cnt;
                }
                if(cnt < 25) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(cnt < 26 && cnt >= k) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 3e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    int cord;
    bool l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            if(l) {
                return 1;
            } else if(other.l) {
                return 0;
            }
            return 1;
        } else {
            return cord < other.cord;
        }
    }
};

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        points.pb({min(i, inv[perm[i]]), true});
        points.pb({max(i, inv[perm[i]]), false});
    }
    sort(points.begin(), points.end());
    ll curr = 0, last = 0, cnt = 0;
    for(auto p : points) {
        if(p.l) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[i] = 'a' + cnt;
                }
                if(cnt < 26 - 1) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(cnt < 26 && cnt >= k) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 5e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    ll cord;
    int l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            return l < other.l;
        } else {
            return cord < other.cord;
        }
    }
};

ll curr, last, cnt, n, k;

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        ll l = min(i, inv[perm[i]]), r = max(i, inv[perm[i]]);
        points.pb({l, 0});
        points.pb({r, 1});
    }
    sort(points.begin(), points.end());
    ll izp = 0;
    for(auto p : points) {
        //cout << p.cord << " " << p.l << " " << curr << endl;
        if(p.l == 0) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[i] = 'a' + cnt;
                }
                if(cnt <= 25) {
                    izp ++;
                }
                //cout << "Ending interval " << last << " " << p.cord << endl;
                if(cnt < 25) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if((cnt <= 26 && izp >= k)) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 5e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    ll cord;
    bool l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            if(l) {
                return 1;
            } else if(other.l) {
                return 0;
            }
            return 1;
        } else {
            return cord < other.cord;
        }
    }
};

ll curr, last, cnt, n, k;

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k; k --;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        ll l = min(i, inv[perm[i]]), r = max(i, inv[perm[i]]);
        points.pb({l, true});
        points.pb({r, false});
    }
    sort(points.begin(), points.end());
    for(auto p : points) {
        if(p.l) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[i] = 'a' + cnt;
                }
                if(cnt < 25) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(cnt < 26 && cnt >= k) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 5e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    ll cord;
    int l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            return l < other.l;
        } else {
            return cord < other.cord;
        }
    }
};

ll curr, last, cnt, n, k;

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        ll l = min(i, inv[perm[i]]), r = max(i, inv[perm[i]]);
        points.pb({l, 0});
        points.pb({r, 1});
    }
    sort(points.begin(), points.end());
    ll izp = 0;
    for(auto p : points) {
        //cout << p.cord << " " << p.l << " " << curr << endl;
        if(p.l == 0) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[perm[i] - 1] = 'a' + cnt;
                }
                if(cnt <= 25) {
                    izp ++;
                }
                //cout << "Ending interval " << last << " " << p.cord << endl;
                if(cnt < 25) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(izp >= k) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 2e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    int cord;
    bool l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            if(l) {
                return 1;
            } else if(other.l) {
                return 0;
            }
            return 1;
        } else {
            return cord < other.cord;
        }
    }
};

vector<P> points;

string ans;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    ans.resize(n);
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        points.pb({min(i, inv[perm[i]]), true});
        points.pb({max(i, inv[perm[i]]), false});
    }
    sort(points.begin(), points.end());
    ll curr = 0, last = 0, cnt = 0;
    for(auto p : points) {
        if(p.l) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[i] = 'a' + cnt;
                }
                if(cnt < 26 - 1) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(cnt < 26 && cnt >= k) {
        cout << "YES" << endl;
        cout << ans;
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 5e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    ll cord;
    int l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            return l < other.l;
        } else {
            return cord < other.cord;
        }
    }
};

ll curr, last, cnt, n, k;

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        perm[i] = i + 1;
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        perm[i] = i + 1;
        ll l = min(i, inv[perm[i]]), r = max(i, inv[perm[i]]);
        points.pb({l, 0});
        points.pb({r, 1});
    }
    sort(points.begin(), points.end());
    ll izp = 0;
    for(auto p : points) {
        //cout << p.cord << " " << p.l << " " << curr << endl;
        if(p.l == 0) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[i] = 'a' + cnt;
                }
                if(cnt <= 25) {
                    izp ++;
                }
                //cout << "Ending interval " << last << " " << p.cord << endl;
                if(cnt < 25) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(izp >= k) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll MAX_N = 3e5 + 10;
ll perm[MAX_N], inv[MAX_N];

struct P {
    ll cord;
    bool l;
    bool operator <(const P &other) const {
        if(cord == other.cord) {
            if(l) {
                return 1;
            } else if(other.l) {
                return 0;
            }
            return 1;
        } else {
            return cord < other.cord;
        }
    }
};

ll curr, last, cnt, n, k;

vector<P> points;

char ans[MAX_N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k; k --;
    for(int i = 0; i < n; i ++) {
        cin >> perm[i];
        inv[perm[i]] = i;
    }
    for(ll i = 0; i < n; i ++) {
        cin >> perm[i];
        ll l = min(i, inv[perm[i]]), r = max(i, inv[perm[i]]);
        points.pb({l, true});
        points.pb({r, false});
    }
    sort(points.begin(), points.end());
    for(auto p : points) {
        if(p.l) {
            if(curr == 0) {
                last = p.cord;
            }
            curr ++;
        } else {
            if(curr == 1) {
                for(int i = last; i <= p.cord; i ++) {
                    ans[i] = 'a' + cnt;
                }
                if(cnt < 25) {
                    cnt ++;
                }
            }
            curr --;
        }
    }
    if(cnt < 26 && cnt >= k) {
        cout << "YES" << endl;
        for(int i = 0; i < n; i ++) {
            cout << ans[i];
        }
    } else {
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int p1[N], p2[N], v[N], ans[N], p[N], sub[N], w[N];
int sum[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    // cout << ans << " updated\n";
    if (sub[u] < sub[v]) swap(u, v);
    sub[u] += sub[v];
    p[v] = u;
}

void solve() {
    int n, k, i, x;
    cin >> n >> k;
    string s;
    for (i=1;i<=n;i++) {
        ans[i] = -1;
        p[i] = i;
        sub[i] = 1;
    }
    for (i=1;i<=n;i++) {
        cin >> x;
        v[i] = x;
        p1[x] = i+1;
    }
    for (i=1;i<=n;i++) {
        cin >> x;
        w[i] = x;
        p2[x] = i+1;
    }
    for (i=1;i<=n;i++) {
        int l = p1[x], r = p2[x];
        if (l > r) swap(l, r);
        if (l == r) continue;
        sum[l+1]++;
        sum[r+1]--;
    }
    for (i=1;i<=n;i++) sum[i] += sum[i-1];
    for (i=2;i<=n;i++) if (sum[i] > 0) {
        merge(v[i], v[i-1]);
        merge(w[i], w[i-1]);
    }
    int roots = 0;
    for (i=1;i<=n;i++) if (p[i] == i) {
        roots++;
    }
    if (roots < k) {
        cout << "NO\n";
        return;
    }
    int j = 0;
    for (i=0;i<n;i++) {
        int now = v[i];
        if (ans[root(now)] == -1) {
            ans[root(now)] = j;
            j++;
            j = max(j, k-1);
        }
    }
    cout << "YES\n";
    for (i=0;i<n;i++) {
        int j = ans[root(v[i])];
        cout << (char)(j + 'a');
    }
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int p1[N], p2[N], v[N], ans[N], p[N], sub[N], w[N];
int sum[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    // cout << ans << " updated\n";
    if (sub[u] < sub[v]) swap(u, v);
    sub[u] += sub[v];
    p[v] = u;
}

void solve() {
    int n, k, i, x;
    cin >> n >> k;
    string s;
    sum[0] = 0;
    for (i=1;i<=n;i++) {
        ans[i] = -1;
        p[i] = i;
        sub[i] = 1;
        sum[i] = 0;
    }
    for (i=1;i<=n;i++) {
        cin >> x;
        v[i] = x;
        p1[x] = i;
    }
    for (i=1;i<=n;i++) {
        cin >> x;
        w[i] = x;
        p2[x] = i;
    }
    for (i=1;i<=n;i++) {
        int l = p1[i], r = p2[i];
        if (l > r) swap(l, r);
        if (l == r) continue;
        // cout << l+1 << " " << r << " merge\n";
        sum[l+1]++;
        sum[r+1]--;
    }
    for (i=1;i<=n;i++) sum[i] += sum[i-1];
    for (i=2;i<=n;i++) if (sum[i] > 0) {
        merge(v[i], v[i-1]);
        merge(w[i], w[i-1]);
    }
    int roots = 0;
    // cout << "Roots : ";
    for (i=1;i<=n;i++) if (p[i] == i) {
        roots++;
        // cout << i << " \n"[i==n];
    }
    if (roots < k) {
        cout << "NO\n";
        return;
    }
    int j = 0;
    for (i=1;i<=n;i++) {
        int now = v[i];
        if (ans[root(now)] == -1) {
            ans[root(now)] = j;
            // cout << root(now) << " set " << j << '\n';
            j++;
            j = max(j, k-1);
        }
    }
    cout << "YES\n";
    for (i=1;i<=n;i++) {
        int j = ans[root(v[i])];
        cout << (char)(j + 'a');
    }
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int v[N], w[N], mx[N], p[N], sub[N], ans[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u  = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    if (sub[u] < sub[v]) swap(u, v);
    mx[u] = max(mx[u], mx[v]);
    sub[u] += sub[v];
    p[v] = u;
}

int sgn (int x) {
    if (x < 0) return -1;
    return 1;
}

void solve() {
    int n, i, k, j;
    cin >> n >> k;
    for (i=1;i<=n;i++) {
        cin >> v[i];
        p[i] = i;
        sub[i] = 1;
        mx[v[i]] = i;
    }
    for (i=1;i<=n;i++) {
        cin >> w[i];
        mx[w[i]] = max(mx[w[i]], i);
    }
    for (i=1;i<=n;i++) {
        merge(v[i], w[i]);
    }
    int fill = 0, dist = 0;
    for (i=1;i<=n;i++) {
        int go = mx[v[i]];
        ans[i] = fill;
        dist++;
        fill = max(fill+1, k-1);
        for (j=i+1;j<=go;j++) {
            ans[j] = ans[i];
        }
        i = go;
    }
    if (dist < k) {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
    for (i=1;i<=n;i++) cout << (char)('a'+ans[i]);
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int v[N], w[N], mx[N], p[N], sub[N], ans[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u  = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    if (sub[u] < sub[v]) swap(u, v);
    mx[u] = max(mx[u], mx[v]);
    sub[u] += sub[v];
    p[v] = u;
}
void solve() {
    int n, i, k, j;
    cin >> n >> k;
    for (i=1;i<=n;i++) {
        cin >> v[i];
        p[i] = i;
        sub[i] = 1;
        mx[v[i]] = i;
    }
    for (i=1;i<=n;i++) {
        cin >> w[i];
        mx[w[i]] = max(mx[w[i]], i);
    }
    for (i=1;i<=n;i++) {
        merge(v[i], w[i]);
    }
    int fill = 0, dist = 0;
    for (i=1;i<=n;i++) {
        int go = mx[root(v[i])];
        j = i+1;
        while(j <= go) {
            merge(v[j], v[i]);
            go = mx[root(v[i])];
            j++;
        }
        for (j=i;j<=go;j++) ans[v[j]] = fill;
        fill = max(fill+1, k-1);
        ++dist;
        i = go;
    }
    if (dist < k) {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
    for (i=1;i<=n;i++) cout << (char)('a'+ans[i]);
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int v[N], w[N], mx[N], p[N], sub[N], ans[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u  = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    if (sub[u] < sub[v]) swap(u, v);
    mx[u] = max(mx[u], mx[v]);
    sub[u] += sub[v];
    p[v] = u;
}

int sgn (int x) {
    if (x < 0) return -1;
    return 1;
}

void solve() {
    int n, i, k, j;
    cin >> n >> k;
    for (i=1;i<=n;i++) {
        cin >> v[i];
        p[i] = i;
        sub[i] = 1;
        mx[v[i]] = i;
    }
    for (i=1;i<=n;i++) {
        cin >> w[i];
        mx[w[i]] = max(mx[w[i]], i);
    }
    for (i=1;i<=n;i++) {
        merge(v[i], w[i]);
    }
    int fill = 0, dist = 0;
    for (i=1;i<=n;i++) {
        int go = mx[root(v[i])];
        ans[v[i]] = fill;
        dist++;
        fill = max(fill+1, k-1);
        for (j=i+1;j<=go;j++) {
            ans[v[j]] = ans[v[i]];
        }
        i = go;
    }
    if (dist < k) {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
    for (i=1;i<=n;i++) cout << (char)('a'+ans[i]);
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int v[N], w[N], mx[N], p[N], sub[N], ans[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u  = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    if (sub[u] < sub[v]) swap(u, v);
    mx[u] = max(mx[u], mx[v]);
    sub[u] += sub[v];
    p[v] = u;
}
void solve() {
    int n, i, k, j;
    cin >> n >> k;
    for (i=1;i<=n;i++) {
        cin >> v[i];
        p[i] = i;
        sub[i] = 1;
        mx[v[i]] = i;
    }
    for (i=1;i<=n;i++) {
        cin >> w[i];
        mx[w[i]] = max(mx[w[i]], i);
    }
    for (i=1;i<=n;i++) {
        merge(v[i], w[i]);
    }
    int fill = 0, dist = 0;
    for (i=1;i<=n;i++) {
        int go = mx[root(v[i])];
        assert(go >= i);
        j = i+1;
        while(j <= go) {
            merge(v[j], v[i]);
            go = mx[root(v[i])];
            j++;
        }
        for (j=i;j<=go;j++) ans[v[j]] = fill;
        fill = min(fill+1, k-1);
        ++dist;
        i = go;
    }
    if (dist < k) {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
    for (i=1;i<=n;i++) cout << (char)('a'+ans[i]);
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int p1[N], p2[N], v[N], ans[N], p[N], sub[N], w[N];
int sum[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    // cout << ans << " updated\n";
    if (sub[u] < sub[v]) swap(u, v);
    sub[u] += sub[v];
    p[v] = u;
}

void solve() {
    int n, k, i, x;
    cin >> n >> k;
    string s;
    for (i=1;i<=n;i++) {
        ans[i] = -1;
        p[i] = i;
        sub[i] = 1;
    }
    for (i=1;i<=n;i++) {
        cin >> x;
        v[i] = x;
        p1[x] = i;
    }
    for (i=1;i<=n;i++) {
        cin >> x;
        w[i] = x;
        p2[x] = i;
    }
    for (i=1;i<=n;i++) {
        int l = p1[x], r = p2[x];
        if (l > r) swap(l, r);
        if (l == r) continue;
        // cout << l+1 << " " << r << " merge\n";
        sum[l+1]++;
        sum[r+1]--;
    }
    for (i=1;i<=n;i++) sum[i] += sum[i-1];
    for (i=2;i<=n;i++) if (sum[i] > 0) {
        merge(v[i], v[i-1]);
        merge(w[i], w[i-1]);
    }
    int roots = 0;
    // cout << "Roots : ";
    for (i=1;i<=n;i++) if (p[i] == i) {
        roots++;
        // cout << i << " \n"[i==n];
    }
    if (roots < k) {
        cout << "NO\n";
        return;
    }
    int j = 0;
    for (i=1;i<=n;i++) {
        int now = v[i];
        if (ans[root(now)] == -1) {
            ans[root(now)] = j;
            // cout << root(now) << " set " << j << '\n';
            j++;
            j = max(j, k-1);
        }
    }
    cout << "YES\n";
    for (i=1;i<=n;i++) {
        int j = ans[root(v[i])];
        cout << (char)(j + 'a');
    }
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int v[N], w[N], mx[N], p[N], sub[N], ans[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u  = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    if (sub[u] < sub[v]) swap(u, v);
    mx[u] = max(mx[u], mx[v]);
    sub[u] += sub[v];
    p[v] = u;
}

int sgn (int x) {
    if (x < 0) return -1;
    return 1;
}

void solve() {
    int n, i, k, j;
    cin >> n >> k;
    for (i=1;i<=n;i++) {
        cin >> v[i];
        p[i] = i;
        sub[i] = 1;
        mx[v[i]] = i;
    }
    for (i=1;i<=n;i++) {
        cin >> w[i];
        mx[w[i]] = max(mx[w[i]], i);
    }
    for (i=1;i<=n;i++) {
        merge(v[i], w[i]);
    }
    int fill = 0, dist = 0;
    for (i=1;i<=n;i++) {
        int go = mx[v[i]];
        ans[v[i]] = fill;
        dist++;
        fill = max(fill+1, k-1);
        for (j=i+1;j<=go;j++) {
            ans[v[j]] = ans[v[i]];
        }
        i = go;
    }
    if (dist < k) {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
    for (i=1;i<=n;i++) cout << (char)('a'+ans[i]);
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int v[N], w[N], mx[N], p[N], sub[N], ans[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u  = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    if (sub[u] < sub[v]) swap(u, v);
    mx[u] = max(mx[u], mx[v]);
    sub[u] += sub[v];
    p[v] = u;
}

int sgn (int x) {
    if (x < 0) return -1;
    return 1;
}

void solve() {
    int n, i, k, j;
    cin >> n >> k;
    for (i=1;i<=n;i++) {
        cin >> v[i];
        p[i] = i;
        sub[i] = 1;
        mx[v[i]] = i;
    }
    for (i=1;i<=n;i++) {
        cin >> w[i];
        mx[w[i]] = max(mx[w[i]], i);
    }
    for (i=1;i<=n;i++) {
        merge(v[i], w[i]);
    }
    int fill = 0, dist = 0;
    for (i=1;i<=n;i++) {
        int go = mx[root(v[i])];
        j = i+1;
        while(j <= go) {
            merge(v[j], v[i]);
            go = mx[root(v[i])];
            j++;
        }
        ans[root(v[i])] = fill;
        fill = max(fill+1, k-1);
        ++dist;
        i = go;
    }
    if (dist < k) {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
    for (i=1;i<=n;i++) cout << (char)('a'+ans[root(i)]);
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
// const LL INF = 1e18;
// const int MOD = 998244353;

using namespace std;

int p1[N], p2[N], v[N], ans[N], p[N], sub[N];
int sum[N];

int root(int u) {
    while(u != p[u]) {
        p[u] = p[p[u]];
        u = p[u];
    }
    return u;
}

void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    // cout << ans << " updated\n";
    if (sub[u] < sub[v]) swap(u, v);
    sub[u] += sub[v];
    p[v] = u;
}

void solve() {
    int n, k, i, x;
    cin >> n >> k;
    string s;
    for (i=1;i<=n;i++) {
        ans[i] = -1;
        p[i] = i;
        sub[i] = 1;
    }
    for (i=0;i<n;i++) {
        cin >> x;
        v[i] = x;
        p1[x] = i+1;
    }
    for (i=0;i<n;i++) {
        cin >> x;
        p2[x] = i+1;
    }
    for (i=1;i<=n;i++) {
        int l = p1[x], r = p2[x];
        if (l > r) swap(l, r);
        if (l == r) continue;
        sum[l+1]++;
        sum[r+1]--;
    }
    for (i=1;i<=n;i++) sum[i] += sum[i-1];
    for (i=2;i<=n;i++) if (sum[i] > 0) {
        merge(i, i-1);
    }
    int roots = 0;
    for (i=1;i<=n;i++) if (p[i] == i) {
        roots++;
    }
    if (roots < k) {
        cout << "NO\n";
        return;
    }
    int j = 0;
    for (i=0;i<n;i++) {
        int now = v[i];
        if (ans[root(now)] == -1) {
            ans[root(now)] = j;
            j++;
            j = max(j, k-1);
        }
    }
    cout << "YES\n";
    for (i=0;i<n;i++) {
        int j = ans[root(v[i])];
        cout << (char)(j + 'a');
    }
    cout << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    for (int t=1; t<=T; t++) {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n,k;
    cin>>n>>k;
    vector<char> temp(n,'@');
    int arr[n],arr1[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    for(int i=0;i<n;i++)cin>>arr1[i];
    int a=0,b=0;
    char x='a';
    set<int> fv;
    for(int i=0;i<n;i++){
        a++;
        fv.insert(arr[i]);
        fv.insert(arr1[i]);
        if(fv.size()==a){
            for(auto y:fv){
                temp[y-1]=x;
            }
            b++;
            if(x<'z')x++;
            fv.clear();
            a=0;
        }
    }
    if(b>=k){
        cout<<"YES"<<endl;
        for(int i=0;i<temp.size();i++)cout<<temp[i];
    }
    else{
        cout<<"NO"<<endl;
    }
}


/* author Dc-HITMAN */
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")*/
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//#define TRACE

//#ifdef TRACE
/*    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
//#else
//#define trace(...)
//    #endif*/

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long  double ld;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;

struct UF {
    vi e;
    UF(int n) : e   (n, -1) {}
    bool same_set(int a, int b) { return find(a) == find(b); }
    int size(int x) { return -e[find(x)]; }
    int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
    void join(int a, int b) {
        a = find(a), b = find(b);
        if (a == b) return;
        if (e[a] > e[b]) swap(a, b);
        e[a] += e[b]; e[b] = a;
    }
};

ll p=1e9+7;
//int x=10002;
ll power_(long long int a, ll b){
    if(!b)
        return 1;
    long long int ans = power_(a, b/2);
    ans = (ans*ans)%p;
    if(b%2)
        ans = (ans*a)%p;
    return ans;
}
ll inf=-1e15;
struct Node {
    Node *l = 0, *r = 0;
    ll lo, hi, mset = inf, madd = 0, val = -inf;
    Node(ll lo,ll hi):lo(lo),hi(hi){} // Large i n t e r v a l o f −i n f

    Node(vi& v, ll lo, ll hi) : lo(lo), hi(hi) {
        if (lo + 1 < hi) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(v, lo, mid); r = new Node(v,mid, hi);
            val = min(l->val, r->val);
        }
        else val = v[lo];
    }

    ll query(ll L, ll R) {
        if (R <= lo || hi <= L) return -inf;
        if (L <= lo && hi <= R) return val;
        push();
        return min(l->query(L, R), r->query(L, R));
    }
    void set(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) mset = val = x, madd= 0;
        else {
            push(), l->set(L, R, x), r->set(L, R, x);
            val = min(l->val, r->val);
        }
    }
    void add(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) {
            if (mset != inf) mset += x;
            else madd += x;
            val += x;
        }
        else {
            push(), l->add(L, R, x), r->add(L, R, x);
            val = min(l->val, r->val);
        }
    }

    void push() {
        if (!l) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(lo, mid); r = new Node(mid, hi);
        }
        if (mset != inf)
            l->set(lo,hi,mset), r->set(lo,hi,mset),mset = inf;
        else if (madd)
            l->add(lo,hi,madd), r->add(lo,hi,madd),madd = 0;
    }
};
struct Tree {
    typedef ll T;
    const T LOW =1e8;
    T f(T a, T b) { return min(a,b); }
    ll n;
    vector<T> s;
    Tree() {}
    Tree(ll m, T def=1e8) { init(m, def); }
    void init(ll m, T def) {
        n = 1; while (n < m) n *= 2;
        s.assign(n + m, def);
        s.resize(2 * n, LOW);
        for (ll i = n; i --> 1; )
            s[i] = f(s[i * 2], s[i*2 + 1]);
    }
    void update(ll pos, T val) {
        pos += n;
        s[pos] = val;
        for (pos /= 2; pos >= 1; pos /= 2)
            s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
    }
    T query(ll l, ll r) { return que(1, l, r, 0,n); }
    T que(ll pos, ll l, ll r, ll lo, ll hi) {
        if (r <= lo || hi <= l) return LOW;
        if (l <= lo && hi <= r) return s[pos];
        ll m = (lo + hi) / 2;
        return f(que(2 * pos, l, r, lo, m),que(2 * pos + 1, l, r, m, hi));
    }
};
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n,k;
    cin>>n>>k;
    vector<char> temp(n,'@');
    int arr[n],arr1[n];
    rep(i,n)cin>>arr[i];
    rep(i,n)cin>>arr1[i];
    int a=0,b=0;
    char x='a';
    set<int> fs,se,tr,fr,fv;
    for(int i=1;i<=n;i++){
        fs.insert(i);
        se.insert(i);
    }
    int prev=-1;
    for(int i=0;i<n;i++){
        fs.erase(arr[i]);
        se.erase(arr1[i]);
        fv.insert(arr[i]);fv.insert(arr1[i]);
        if(se.find(arr[i])!=se.end()){
            fr.insert(arr[i]);
        }
        if(fs.find(arr1[i])!=fs.end()){
            tr.insert(arr1[i]);
        }
        if(tr.find(arr[i])!=tr.end())tr.erase(arr[i]);
        if(fr.find(arr1[i])!=fr.end())fr.erase(arr1[i]);
        //cout<<i<<" "<<tr.size()<<" "<<fr.size()<<endl;
        if(tr.size()==0 && fr.size()==0){
            for(auto y:fv){
                //b++;
                temp[y-1]=x;
                //if(x<'z')
                ///x++;
                //fv.clear();
                //cout<<"sfs";
            }
            b++;
            if(x<'z')x++;
            fv.clear();
        }
    }
    if(b>=k){
        cout<<"YES"<<endl;
        //cout<<temp.size();
        rep(i,temp.size())cout<<temp[i];
    }
    else{
        cout<<"NO"<<endl;
    }
}


/* author Dc-HITMAN */
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")*/
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//#define TRACE

//#ifdef TRACE
/*    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
//#else
//#define trace(...)
//    #endif*/

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long  double ld;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;

struct UF {
    vi e;
    UF(int n) : e   (n, -1) {}
    bool same_set(int a, int b) { return find(a) == find(b); }
    int size(int x) { return -e[find(x)]; }
    int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
    void join(int a, int b) {
        a = find(a), b = find(b);
        if (a == b) return;
        if (e[a] > e[b]) swap(a, b);
        e[a] += e[b]; e[b] = a;
    }
};

ll p=1e9+7;
//int x=10002;
ll power_(long long int a, ll b){
    if(!b)
        return 1;
    long long int ans = power_(a, b/2);
    ans = (ans*ans)%p;
    if(b%2)
        ans = (ans*a)%p;
    return ans;
}
ll inf=-1e15;
struct Node {
    Node *l = 0, *r = 0;
    ll lo, hi, mset = inf, madd = 0, val = -inf;
    Node(ll lo,ll hi):lo(lo),hi(hi){} // Large i n t e r v a l o f −i n f

    Node(vi& v, ll lo, ll hi) : lo(lo), hi(hi) {
        if (lo + 1 < hi) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(v, lo, mid); r = new Node(v,mid, hi);
            val = min(l->val, r->val);
        }
        else val = v[lo];
    }

    ll query(ll L, ll R) {
        if (R <= lo || hi <= L) return -inf;
        if (L <= lo && hi <= R) return val;
        push();
        return min(l->query(L, R), r->query(L, R));
    }
    void set(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) mset = val = x, madd= 0;
        else {
            push(), l->set(L, R, x), r->set(L, R, x);
            val = min(l->val, r->val);
        }
    }
    void add(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) {
            if (mset != inf) mset += x;
            else madd += x;
            val += x;
        }
        else {
            push(), l->add(L, R, x), r->add(L, R, x);
            val = min(l->val, r->val);
        }
    }

    void push() {
        if (!l) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(lo, mid); r = new Node(mid, hi);
        }
        if (mset != inf)
            l->set(lo,hi,mset), r->set(lo,hi,mset),mset = inf;
        else if (madd)
            l->add(lo,hi,madd), r->add(lo,hi,madd),madd = 0;
    }
};
struct Tree {
    typedef ll T;
    const T LOW =1e8;
    T f(T a, T b) { return min(a,b); }
    ll n;
    vector<T> s;
    Tree() {}
    Tree(ll m, T def=1e8) { init(m, def); }
    void init(ll m, T def) {
        n = 1; while (n < m) n *= 2;
        s.assign(n + m, def);
        s.resize(2 * n, LOW);
        for (ll i = n; i --> 1; )
            s[i] = f(s[i * 2], s[i*2 + 1]);
    }
    void update(ll pos, T val) {
        pos += n;
        s[pos] = val;
        for (pos /= 2; pos >= 1; pos /= 2)
            s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
    }
    T query(ll l, ll r) { return que(1, l, r, 0,n); }
    T que(ll pos, ll l, ll r, ll lo, ll hi) {
        if (r <= lo || hi <= l) return LOW;
        if (l <= lo && hi <= r) return s[pos];
        ll m = (lo + hi) / 2;
        return f(que(2 * pos, l, r, lo, m),que(2 * pos + 1, l, r, m, hi));
    }
};
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n,k;
    cin>>n>>k;
    vector<char> temp(n,'@');
    int arr[n],arr1[n];
    rep(i,n)cin>>arr[i];
    rep(i,n)cin>>arr1[i];
    int a=0,b=0;
    char x='a';
    set<int> fs,se,tr,fr,fv;
    for(int i=1;i<=n;i++){
        fs.insert(i);
        se.insert(i);
    }
    int prev=-1;
    for(int i=0;i<n-1;i++){
        fs.erase(arr[i]);
        se.erase(arr1[i]);
        fv.insert(arr[i]);fv.insert(arr1[i]);
        if(se.find(arr[i])!=se.end()){
            tr.insert(arr[i]);
        }
        if(fs.find(arr1[i])!=fs.end()){
            fr.insert(arr1[i]);
        }
        if(tr.find(arr[i])!=tr.end())tr.erase(arr[i]);
        if(fr.find(arr1[i])!=fr.end())fr.erase(arr1[i]);
        if(tr.size()==0 && fr.size()==0){
            for(auto y:fv){
                b++;
                temp[y-1]=x;
                //if(x<'z')
                ///x++;
                //fv.clear();
            }
            if(x<'z')x++;
            fv.clear();
        }
    }
    if(b>=k){
        cout<<"YES"<<endl;
        //cout<<temp.size();
        rep(i,temp.size())cout<<temp[i];
    }
    else{
        cout<<"NO"<<endl;
    }
}


/* author Dc-HITMAN */
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")*/
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//#define TRACE

//#ifdef TRACE
/*    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
//#else
//#define trace(...)
//    #endif*/

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long  double ld;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;

struct UF {
    vi e;
    UF(int n) : e   (n, -1) {}
    bool same_set(int a, int b) { return find(a) == find(b); }
    int size(int x) { return -e[find(x)]; }
    int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
    void join(int a, int b) {
        a = find(a), b = find(b);
        if (a == b) return;
        if (e[a] > e[b]) swap(a, b);
        e[a] += e[b]; e[b] = a;
    }
};

ll p=1e9+7;
//int x=10002;
ll power_(long long int a, ll b){
    if(!b)
        return 1;
    long long int ans = power_(a, b/2);
    ans = (ans*ans)%p;
    if(b%2)
        ans = (ans*a)%p;
    return ans;
}
ll inf=-1e15;
struct Node {
    Node *l = 0, *r = 0;
    ll lo, hi, mset = inf, madd = 0, val = -inf;
    Node(ll lo,ll hi):lo(lo),hi(hi){} // Large i n t e r v a l o f −i n f

    Node(vi& v, ll lo, ll hi) : lo(lo), hi(hi) {
        if (lo + 1 < hi) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(v, lo, mid); r = new Node(v,mid, hi);
            val = min(l->val, r->val);
        }
        else val = v[lo];
    }

    ll query(ll L, ll R) {
        if (R <= lo || hi <= L) return -inf;
        if (L <= lo && hi <= R) return val;
        push();
        return min(l->query(L, R), r->query(L, R));
    }
    void set(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) mset = val = x, madd= 0;
        else {
            push(), l->set(L, R, x), r->set(L, R, x);
            val = min(l->val, r->val);
        }
    }
    void add(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) {
            if (mset != inf) mset += x;
            else madd += x;
            val += x;
        }
        else {
            push(), l->add(L, R, x), r->add(L, R, x);
            val = min(l->val, r->val);
        }
    }

    void push() {
        if (!l) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(lo, mid); r = new Node(mid, hi);
        }
        if (mset != inf)
            l->set(lo,hi,mset), r->set(lo,hi,mset),mset = inf;
        else if (madd)
            l->add(lo,hi,madd), r->add(lo,hi,madd),madd = 0;
    }
};
struct Tree {
    typedef ll T;
    const T LOW =1e8;
    T f(T a, T b) { return min(a,b); }
    ll n;
    vector<T> s;
    Tree() {}
    Tree(ll m, T def=1e8) { init(m, def); }
    void init(ll m, T def) {
        n = 1; while (n < m) n *= 2;
        s.assign(n + m, def);
        s.resize(2 * n, LOW);
        for (ll i = n; i --> 1; )
            s[i] = f(s[i * 2], s[i*2 + 1]);
    }
    void update(ll pos, T val) {
        pos += n;
        s[pos] = val;
        for (pos /= 2; pos >= 1; pos /= 2)
            s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
    }
    T query(ll l, ll r) { return que(1, l, r, 0,n); }
    T que(ll pos, ll l, ll r, ll lo, ll hi) {
        if (r <= lo || hi <= l) return LOW;
        if (l <= lo && hi <= r) return s[pos];
        ll m = (lo + hi) / 2;
        return f(que(2 * pos, l, r, lo, m),que(2 * pos + 1, l, r, m, hi));
    }
};
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n,k;
    cin>>n>>k;
    vector<char> temp(n,'@');
    int arr[n],arr1[n];
    rep(i,n)cin>>arr[i];
    rep(i,n)cin>>arr1[i];
    int a=0,b=0;
    char x='a';
    set<int> fv;
    UF dsu(n+3);
    for(int i=0;i<n;i++){
        a++;
        //dsu.join(arr[i],arr1[i]);
        fv.insert(arr[i]);
        fv.insert(arr1[i]);
        if(fv.size()==a){
            for(auto y:fv){
                //b++;
                temp[y-1]=x;
                //if(x<'z')
                ///x++;
                //fv.clear();
                //cout<<"sfs";
            }
            b++;
            if(x<'z')x++;
            fv.clear();
            a=0;
        }
    }
    if(b>=k){
        cout<<"YES"<<endl;
        //cout<<temp.size();
        rep(i,temp.size())cout<<temp[i];
    }
    else{
        cout<<"NO"<<endl;
    }
}


/* author Dc-HITMAN */
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")*/
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//#define TRACE

//#ifdef TRACE
/*    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
//#else
//#define trace(...)
//    #endif*/

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long  double ld;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;

struct UF {
    vi e;
    UF(int n) : e   (n, -1) {}
    bool same_set(int a, int b) { return find(a) == find(b); }
    int size(int x) { return -e[find(x)]; }
    int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
    void join(int a, int b) {
        a = find(a), b = find(b);
        if (a == b) return;
        if (e[a] > e[b]) swap(a, b);
        e[a] += e[b]; e[b] = a;
    }
};

ll p=1e9+7;
//int x=10002;
ll power_(long long int a, ll b){
    if(!b)
        return 1;
    long long int ans = power_(a, b/2);
    ans = (ans*ans)%p;
    if(b%2)
        ans = (ans*a)%p;
    return ans;
}
ll inf=-1e15;
struct Node {
    Node *l = 0, *r = 0;
    ll lo, hi, mset = inf, madd = 0, val = -inf;
    Node(ll lo,ll hi):lo(lo),hi(hi){} // Large i n t e r v a l o f −i n f

    Node(vi& v, ll lo, ll hi) : lo(lo), hi(hi) {
        if (lo + 1 < hi) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(v, lo, mid); r = new Node(v,mid, hi);
            val = min(l->val, r->val);
        }
        else val = v[lo];
    }

    ll query(ll L, ll R) {
        if (R <= lo || hi <= L) return -inf;
        if (L <= lo && hi <= R) return val;
        push();
        return min(l->query(L, R), r->query(L, R));
    }
    void set(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) mset = val = x, madd= 0;
        else {
            push(), l->set(L, R, x), r->set(L, R, x);
            val = min(l->val, r->val);
        }
    }
    void add(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) {
            if (mset != inf) mset += x;
            else madd += x;
            val += x;
        }
        else {
            push(), l->add(L, R, x), r->add(L, R, x);
            val = min(l->val, r->val);
        }
    }

    void push() {
        if (!l) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(lo, mid); r = new Node(mid, hi);
        }
        if (mset != inf)
            l->set(lo,hi,mset), r->set(lo,hi,mset),mset = inf;
        else if (madd)
            l->add(lo,hi,madd), r->add(lo,hi,madd),madd = 0;
    }
};
struct Tree {
    typedef ll T;
    const T LOW =1e8;
    T f(T a, T b) { return min(a,b); }
    ll n;
    vector<T> s;
    Tree() {}
    Tree(ll m, T def=1e8) { init(m, def); }
    void init(ll m, T def) {
        n = 1; while (n < m) n *= 2;
        s.assign(n + m, def);
        s.resize(2 * n, LOW);
        for (ll i = n; i --> 1; )
            s[i] = f(s[i * 2], s[i*2 + 1]);
    }
    void update(ll pos, T val) {
        pos += n;
        s[pos] = val;
        for (pos /= 2; pos >= 1; pos /= 2)
            s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
    }
    T query(ll l, ll r) { return que(1, l, r, 0,n); }
    T que(ll pos, ll l, ll r, ll lo, ll hi) {
        if (r <= lo || hi <= l) return LOW;
        if (l <= lo && hi <= r) return s[pos];
        ll m = (lo + hi) / 2;
        return f(que(2 * pos, l, r, lo, m),que(2 * pos + 1, l, r, m, hi));
    }
};
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n,k;
    cin>>n>>k;
    vector<char> temp(n,'@');
    int arr[n],arr1[n];
    rep(i,n)cin>>arr[i];
    rep(i,n)cin>>arr1[i];
    int a=0,b=0;
    char x='a';
    set<int> fs,se,tr,fr,fv;
    for(int i=1;i<=n;i++){
        fs.insert(i);
        se.insert(i);
    }
    int prev=-1;
    for(int i=0;i<n-1;i++){
        fs.erase(arr[i]);
        se.erase(arr1[i]);
        fv.insert(arr[i]);fv.insert(arr1[i]);
        if(se.find(arr[i])!=se.end()){
            tr.insert(arr[i]);
        }
        if(fs.find(arr1[i])!=fs.end()){
            fr.insert(arr1[i]);
        }
        if(tr.find(arr[i])!=tr.end())tr.erase(arr[i]);
        if(fr.find(arr1[i])!=fr.end())fr.erase(arr1[i]);
        if(tr.size()==0 && fr.size()==0){
            for(auto y:fv){
                //b++;
                temp[y-1]=x;
                //if(x<'z')
                ///x++;
                //fv.clear();
            }
            b++;
            if(x<'z')x++;
            fv.clear();
        }
    }
    if(b>=k){
        cout<<"YES"<<endl;
        //cout<<temp.size();
        rep(i,temp.size())cout<<temp[i];
    }
    else{
        cout<<"NO"<<endl;
    }
}


/* author Dc-HITMAN */
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")*/
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//#define TRACE

//#ifdef TRACE
/*    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
//#else
//#define trace(...)
//    #endif*/

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long  double ld;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;

struct UF {
    vi e;
    UF(int n) : e   (n, -1) {}
    bool same_set(int a, int b) { return find(a) == find(b); }
    int size(int x) { return -e[find(x)]; }
    int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
    void join(int a, int b) {
        a = find(a), b = find(b);
        if (a == b) return;
        if (e[a] > e[b]) swap(a, b);
        e[a] += e[b]; e[b] = a;
    }
};

ll p=1e9+7;
//int x=10002;
ll power_(long long int a, ll b){
    if(!b)
        return 1;
    long long int ans = power_(a, b/2);
    ans = (ans*ans)%p;
    if(b%2)
        ans = (ans*a)%p;
    return ans;
}
ll inf=-1e15;
struct Node {
    Node *l = 0, *r = 0;
    ll lo, hi, mset = inf, madd = 0, val = -inf;
    Node(ll lo,ll hi):lo(lo),hi(hi){} // Large i n t e r v a l o f −i n f

    Node(vi& v, ll lo, ll hi) : lo(lo), hi(hi) {
        if (lo + 1 < hi) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(v, lo, mid); r = new Node(v,mid, hi);
            val = min(l->val, r->val);
        }
        else val = v[lo];
    }

    ll query(ll L, ll R) {
        if (R <= lo || hi <= L) return -inf;
        if (L <= lo && hi <= R) return val;
        push();
        return min(l->query(L, R), r->query(L, R));
    }
    void set(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) mset = val = x, madd= 0;
        else {
            push(), l->set(L, R, x), r->set(L, R, x);
            val = min(l->val, r->val);
        }
    }
    void add(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) {
            if (mset != inf) mset += x;
            else madd += x;
            val += x;
        }
        else {
            push(), l->add(L, R, x), r->add(L, R, x);
            val = min(l->val, r->val);
        }
    }

    void push() {
        if (!l) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(lo, mid); r = new Node(mid, hi);
        }
        if (mset != inf)
            l->set(lo,hi,mset), r->set(lo,hi,mset),mset = inf;
        else if (madd)
            l->add(lo,hi,madd), r->add(lo,hi,madd),madd = 0;
    }
};
struct Tree {
    typedef ll T;
    const T LOW =1e8;
    T f(T a, T b) { return min(a,b); }
    ll n;
    vector<T> s;
    Tree() {}
    Tree(ll m, T def=1e8) { init(m, def); }
    void init(ll m, T def) {
        n = 1; while (n < m) n *= 2;
        s.assign(n + m, def);
        s.resize(2 * n, LOW);
        for (ll i = n; i --> 1; )
            s[i] = f(s[i * 2], s[i*2 + 1]);
    }
    void update(ll pos, T val) {
        pos += n;
        s[pos] = val;
        for (pos /= 2; pos >= 1; pos /= 2)
            s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
    }
    T query(ll l, ll r) { return que(1, l, r, 0,n); }
    T que(ll pos, ll l, ll r, ll lo, ll hi) {
        if (r <= lo || hi <= l) return LOW;
        if (l <= lo && hi <= r) return s[pos];
        ll m = (lo + hi) / 2;
        return f(que(2 * pos, l, r, lo, m),que(2 * pos + 1, l, r, m, hi));
    }
};
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n,k;
    cin>>n>>k;
    vector<char> temp(n,'@');
    int arr[n],arr1[n];
    rep(i,n)cin>>arr[i];
    rep(i,n)cin>>arr1[i];
    int a=0,b=0;
    char x='a';
    set<int> fs,se,tr,fr,fv;
    for(int i=1;i<=n;i++){
        fs.insert(i);
        se.insert(i);
    }
    int prev=-1;
    for(int i=0;i<n-1;i++){
        fs.erase(arr[i]);
        se.erase(arr1[i]);
        fv.insert(arr[i]);fv.insert(arr1[i]);
        //if(se.find(arr[i])!=se.end()){
            tr.insert(arr1[i]);
        //}
       // if(fs.find(arr1[i])!=fs.end()){
            fr.insert(arr[i]);
        //}
        if(tr.find(arr[i])!=tr.end())tr.erase(arr[i]);
        if(fr.find(arr1[i])!=fr.end())fr.erase(arr1[i]);
        if(tr.size()==0 && fr.size()==0){
            for(auto y:fv){
                //b++;
                temp[y-1]=x;
                //if(x<'z')
                ///x++;
                //fv.clear();
            }
            b++;
            if(x<'z')x++;
            fv.clear();
        }
    }
    if(b>=k){
        cout<<"YES"<<endl;
        //cout<<temp.size();
        rep(i,temp.size())cout<<temp[i];
    }
    else{
        cout<<"NO"<<endl;
    }
}


/* author Dc-HITMAN */
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")*/
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//#define TRACE

//#ifdef TRACE
/*    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
//#else
//#define trace(...)
//    #endif*/

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long  double ld;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;

struct UF {
    vi e;
    UF(int n) : e   (n, -1) {}
    bool same_set(int a, int b) { return find(a) == find(b); }
    int size(int x) { return -e[find(x)]; }
    int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
    void join(int a, int b) {
        a = find(a), b = find(b);
        if (a == b) return;
        if (e[a] > e[b]) swap(a, b);
        e[a] += e[b]; e[b] = a;
    }
};

ll p=1e9+7;
//int x=10002;
ll power_(long long int a, ll b){
    if(!b)
        return 1;
    long long int ans = power_(a, b/2);
    ans = (ans*ans)%p;
    if(b%2)
        ans = (ans*a)%p;
    return ans;
}
ll inf=-1e15;
struct Node {
    Node *l = 0, *r = 0;
    ll lo, hi, mset = inf, madd = 0, val = -inf;
    Node(ll lo,ll hi):lo(lo),hi(hi){} // Large i n t e r v a l o f −i n f

    Node(vi& v, ll lo, ll hi) : lo(lo), hi(hi) {
        if (lo + 1 < hi) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(v, lo, mid); r = new Node(v,mid, hi);
            val = min(l->val, r->val);
        }
        else val = v[lo];
    }

    ll query(ll L, ll R) {
        if (R <= lo || hi <= L) return -inf;
        if (L <= lo && hi <= R) return val;
        push();
        return min(l->query(L, R), r->query(L, R));
    }
    void set(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) mset = val = x, madd= 0;
        else {
            push(), l->set(L, R, x), r->set(L, R, x);
            val = min(l->val, r->val);
        }
    }
    void add(ll L, ll R, ll x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) {
            if (mset != inf) mset += x;
            else madd += x;
            val += x;
        }
        else {
            push(), l->add(L, R, x), r->add(L, R, x);
            val = min(l->val, r->val);
        }
    }

    void push() {
        if (!l) {
            ll mid = lo + (hi - lo)/2;
            l = new Node(lo, mid); r = new Node(mid, hi);
        }
        if (mset != inf)
            l->set(lo,hi,mset), r->set(lo,hi,mset),mset = inf;
        else if (madd)
            l->add(lo,hi,madd), r->add(lo,hi,madd),madd = 0;
    }
};
struct Tree {
    typedef ll T;
    const T LOW =1e8;
    T f(T a, T b) { return min(a,b); }
    ll n;
    vector<T> s;
    Tree() {}
    Tree(ll m, T def=1e8) { init(m, def); }
    void init(ll m, T def) {
        n = 1; while (n < m) n *= 2;
        s.assign(n + m, def);
        s.resize(2 * n, LOW);
        for (ll i = n; i --> 1; )
            s[i] = f(s[i * 2], s[i*2 + 1]);
    }
    void update(ll pos, T val) {
        pos += n;
        s[pos] = val;
        for (pos /= 2; pos >= 1; pos /= 2)
            s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
    }
    T query(ll l, ll r) { return que(1, l, r, 0,n); }
    T que(ll pos, ll l, ll r, ll lo, ll hi) {
        if (r <= lo || hi <= l) return LOW;
        if (l <= lo && hi <= r) return s[pos];
        ll m = (lo + hi) / 2;
        return f(que(2 * pos, l, r, lo, m),que(2 * pos + 1, l, r, m, hi));
    }
};
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n,k;
    cin>>n>>k;
    vector<char> temp(n,'@');
    int arr[n],arr1[n];
    rep(i,n)cin>>arr[i];
    rep(i,n)cin>>arr1[i];
    int a=0,b=0;
    char x='a';
    set<int> fv;
    UF dsu(n+3);
    for(int i=0;i<n;i++){
        a++;
        dsu.join(arr[i],arr1[i]);
        fv.insert(arr[i]);
        fv.insert(arr1[i]);
        if(dsu.size(arr[i])==a){
            for(auto y:fv){
                //b++;
                temp[y-1]=x;
                //if(x<'z')
                ///x++;
                //fv.clear();
                //cout<<"sfs";
            }
            b++;
            if(x<'z')x++;
            fv.clear();
            a=0;
        }
    }
    if(b>=k){
        cout<<"YES"<<endl;
        //cout<<temp.size();
        rep(i,temp.size())cout<<temp[i];
    }
    else{
        cout<<"NO"<<endl;
    }
}


#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define fr front()
#define pb push_back
#define sqr(a) ((a)*(a))
#define pll pair<ll,ll>
#define y1 Enkognit

using namespace std;

const ll MOD = 998244353;

ll n, m, k, q, l, r, i, j, x, y, ans, a[300001], b[300001];
ll tt[300001];
ll z[300001];
char c[300001];

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    ll p=0;
    for (int i = 0; i < n; i++)
    {
        if (tt[a[i]]) p--; else p++;
        tt[a[i]]++;
        if (tt[b[i]]) p--; else p++;
        tt[b[i]]++;
        if (p==0) z[i]=1;
    }
    ll r=0;
    for (int i = 0; i < n; i++)
    {
        c[a[i]]=r+'a';
        r+=z[i];
        if ((r+'a'>'z' && i<n-1) || r>m) r--;
    }
    if (r>=m) {cout << "YES\n";for (int i = 1; i <= n; i++) cout << c[i];} else cout <<"NO\n";
    return 0;
}
/*
10 3
9 30 45 2 5 7 10 3 16 22
*/