func_code_string: #include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) { return a > b ? a : b; }   long long min(long long a, long long b) { return a < b ? a : b; }   double max(double a, double b) { return a > b ? a : b; }   double min(double a, double b) { return a < b ? a : b; }   long long modd(long long a) {     if (a < 0LL) return a * -1LL;     return a;   }   double modd(double a) {     if (a < 0.0) return a * -1.0;     return a;   }   long long modulo(long long a) { return a % 1000000007LL; }   long long power(long long k, long long p) {     if (p == 0) return 1LL;     long long P = power(k, p / 2LL);     P = (P * P) % 1000000007LL;     if (p % 2 == 1) P = (P * k) % 1000000007LL;     return P;   }   struct p_str {     long long val, idx;     char ch;   };   bool comp(p_str& a, p_str& b) { return a.val < b.val; }   void solve() {     string s;     cin >> s;     long long m;     cin >> m;     long long b[m];     for (long long i = 0; i < m; i++) {       cin >> b[i];     }     long long cnt[26];     memset(cnt, 0, sizeof(cnt));     for (long long i = 0; i < s.length(); i++) {       cnt[s[i] -  a ]++;     }     char t[m];     long long i_cnt = 26;     while (1) {       bool f = 1;       long long mn_i = -1;       for (long long i = 0; i < m; i++) {         if (b[i] == 0) {           mn_i = i;           f = 0;           break;         }       }       if (f) {         break;       }       vector<long long> zero_pos;       for (long long i = 0; i < m; i++) {         if (b[i] == 0) {           zero_pos.push_back(i);         }       }       long long c = zero_pos.size();       i_cnt--;       while (i_cnt >= 0 && cnt[i_cnt] < c) {         i_cnt--;       }       for (long long i = 0; i < zero_pos.size(); i++) {         t[zero_pos[i]] = (char)(i_cnt +  a );       }       for (long long j = 0; j < zero_pos.size(); j++) {         long long pos = zero_pos[j];         for (long long i = 0; i < m; i++) {           if (b[i] > 0) {             b[i] -= modd(i - pos);           }         }         b[pos] = -1;       }     }     for (long long i = 0; i < m; i++) {       cout << t[i];     }     cout << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }   