func_code_string: #include <bits/stdc++.h>   using namespace std;   using vi = vector<int>;   using vvi = vector<vi>;   using ll = long long;   using vll = vector<ll>;   using vvll = vector<vll>;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   ll power[40];   void dfs(int id, vi& v, vi& s) {     if (id < v.size()) {       s.push_back(v[id]);       dfs(id * 2, v, s);       dfs(id * 2 + 1, v, s);     }   }   void solve() {     int h, g, num;     cin >> h >> g;     vi v(power[h]);     vvi mins(power[g], vi());     set<int> fin;     for (int i = 1; i < power[h]; i++) {       cin >> v[i];     }     for (int i = 0; i < power[g - 1]; i++) {       dfs(i + power[g - 1], v, mins[i + power[g - 1]]);       sort(mins[i + power[g - 1]].begin(), mins[i + power[g - 1]].end(),            greater<int>());     }     for (int i = g; i > 0; i--) {       for (int j = power[i - 1]; j < power[i]; j++) {         fin.insert(*mins[j].rbegin());       }       if (i == 1) {         break;       }       for (int j = power[i - 1]; j < power[i]; j += 2) {         num = max(*mins[j].rbegin(), *mins[j + 1].rbegin());         mins[j].pop_back();         mins[j + 1].pop_back();         mins[j / 2].push_back(v[j / 2]);         merge(mins[j].begin(), mins[j].end(), mins[j + 1].begin(),               mins[j + 1].end(), std::back_inserter(mins[j / 2]), greater<int>());         while (*mins[j / 2].rbegin() < num) {           mins[j / 2].pop_back();         }       }     }     ll sum = 0;     vi print;     print.reserve(power[h] - 1);     for (int i = 1; i < power[h]; i++) {       if (fin.find(v[i]) == fin.end()) {         print.push_back(i);       } else {         sum += v[i];       }     }     reverse(print.begin(), print.end());     cout << sum <<   n ;     for (int i : print) {       cout << i <<    ;     }     cout <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     power[0] = 1;     for (int i = 1; i < 40; i++) {       power[i] = 2ll * power[i - 1];     }     int t;     cin >> t;     while (t--) {       solve();     }   }   