func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int q;     cin >> q;     for (int qq = 0; qq < int(q); qq++) {       string s;       cin >> s;       int n;       cin >> n;       vector<int> b(n);       for (int i = 0; i < int(n); i++) cin >> b[i];       vector<vector<int>> groups;       while (true) {         vector<int> pos;         for (int i = 0; i < int(n); i++)           if (b[i] == 0) pos.push_back(i);         if (pos.empty()) break;         groups.push_back(pos);         for (int i = 0; i < int(n); i++)           if (b[i] == 0)             b[i] = INT_MAX;           else             for (int pp : pos) b[i] -= abs(i - pp);       }       map<char, int> cnts;       for (int i = 0; i < int(s.size()); i++) cnts[s[i]]++;       auto j = cnts.rbegin();       string t(n,  ? );       for (auto g : groups) {         while (j->second < g.size()) j++;         for (int pp : g) t[pp] = j->first;         j++;       }       cout << t << endl;     }   }   