//#pragma GCC optimize ("O3")
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> x(k + 1), c(k + 1);
for (int i{1}; i <= k; ++i) cin >> x[i];
for (int i{1}; i <= k; ++i) cin >> c[i];
vector<char> ans(n);
char abc{'a'};
ans[0] = 'a', ans[1] = 'b', ans[2] = 'c';
x[0] = 3, c[0] = 3;
for (int i{1}; i <= k; ++i) {
if (x[i] - x[i - 1] < c[i] - c[i - 1]) return cout << "NO\n", []{}();
int i2{x[i - 1] + c[i] - c[i - 1]};
for (int j{x[i - 1]}; j < i2; ++j) ans[j] = 'c' + i;
for (int j{i2}; j < x[i]; ++j) ans[j] = abc, abc = (abc == 'c' ? 'a' : abc + 1);
}
cout << "YES\n";
for (int i{0}; i < n; ++i) cout << ans[i];
cout << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t{1};
cin >> t;
while (t--) solve();
}
1633C - Kill the Monster | 1611A - Make Even |
1030B - Vasya and Cornfield | 1631A - Min Max Swap |
1296B - Food Buying | 133A - HQ9+ |
1650D - Twist the Permutation | 1209A - Paint the Numbers |
1234A - Equalize Prices Again | 1613A - Long Comparison |
1624B - Make AP | 660B - Seating On Bus |
405A - Gravity Flip | 499B - Lecture |
709A - Juicer | 1358C - Celex Update |
1466B - Last minute enhancements | 450B - Jzzhu and Sequences |
1582C - Grandma Capa Knits a Scarf | 492A - Vanya and Cubes |
217A - Ice Skating | 270A - Fancy Fence |
181A - Series of Crimes | 1638A - Reverse |
1654C - Alice and the Cake | 369A - Valera and Plates |
1626A - Equidistant Letters | 977D - Divide by three multiply by two |
1654B - Prefix Removals | 1654A - Maximum Cake Tastiness |