func_code_string: #include <bits/stdc++.h>   using namespace std;   int mod = 998244353;   const int M = 2e5 + 10;   const int N = 5e2 + 10;   inline long long read() {     long long b = 1, sum = 0;     char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) b = -1;       c = getchar();     }     while (isdigit(c)) {       sum = sum * 10 + c -  0 ;       c = getchar();     }     return b * sum;   }   int hs, gs;   int n, m, k, T;   int h, g, a[1 << 22];   long long sum;   vector<int> ans;   void change(int x) {     int l = 2 * x, r = 2 * x + 1;     if (a[l] == 0 && a[r] == 0) {       a[x] = 0;     } else {       if (a[l] > a[r]) {         a[x] = a[l];         change(l);       } else {         a[x] = a[r];         change(r);       }     }   }   int pull(int x) {     int l = 2 * x, r = 2 * x + 1;     if (a[l] == 0 && a[r] == 0) {       return x;     } else {       if (a[l] > a[r]) {         return pull(l);       } else {         return pull(r);       }     }   }   void solv(int x) {     if (a[x] == 0) return;     int l = 2 * x, r = 2 * x + 1;     while (pull(x) >= gs) {       ans.push_back(x);       sum -= a[x];       change(x);     }     solv(l);     solv(r);   }   int main() {     int i, j;     T = read();     while (T--) {       sum = 0;       h = read(), g = read();       hs = (1 << h);       gs = (1 << g);       n = hs - gs;       for (i = 1; i <= hs - 1; i++) {         a[i] = read();         a[i + n] = a[i + 2 * n] = 0;         sum += a[i];       }       ans.clear();       solv(1);       printf( %lld n , sum);       for (i = 0; i < ans.size(); i++) {         printf( %d  , ans[i]);       }       printf(  n );     }     return 0;   }   