func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll MOD = 1e9 + 7, N = 1e5 + 10;   void test() {     string s;     cin >> s;     vector<ll> cnt(26);     for (auto c : s) {       cnt[c -  a ]++;     }     ll m;     cin >> m;     vector<ll> b(m);     for (ll i = 0; i < m; i++) {       cin >> b[i];     }     ll n = s.length();     vector<ll> done(m);     string res(m,  . );     ll up = 25;     for (ll i = 0; i < m; i++) {       ll mx = 1e9;       for (ll j = 0; j < m; j++) {         if (done[j]) continue;         mx = min(mx, b[j]);       }       if (mx == 1e9) break;       vector<ll> pos;       for (ll j = 0; j < m; j++) {         if (done[j]) continue;         if (mx == b[j]) {           pos.push_back(j);         }       }       ll v;       for (ll j = up; j >= 0; --j) {         if (cnt[j] >= pos.size()) {           v = j;           break;         }       }       up = v - 1;       for (auto &e : pos) {         res[e] = char(v +  a );       }       for (auto &e : pos) {         for (ll j = 0; j < m; j++) {           if (!done[j]) {             b[j] -= abs(j - e);           }         }       }       for (auto &e : pos) done[e] = 1;     }     cout << res <<   n ;     return;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ll tt = 1;     cin >> tt;     for (ll i = 0; i < tt; i++) test();     return 0;   }   