Problem: Drazil likes heap very much. So he created a problem with heap:

There is a max heap with a height h implemented on the array. The details of this heap are the following:

This heap contains exactly 2^h - 1 distinct positive non-zero integers. All integers are distinct. These numbers are stored in the array a indexed from 1 to 2^h-1. For any 1 < i < 2^h, a[i] < a[\left ⌊{i/2}\right ⌋].

Now we want to reduce the height of this heap such that the height becomes g with exactly 2^g-1 numbers in heap. To reduce the height, we should perform the following action 2^h-2^g times:

Choose an index i, which contains an element and call the following function f in index i:

<image>

Note that we suppose that if a[i]=0, then index i don't contain an element.

After all operations, the remaining 2^g-1 element must be located in indices from 1 to 2^g-1. Now Drazil wonders what's the minimum possible sum of the remaining 2^g-1 elements. Please find this sum and find a sequence of the function calls to achieve this value.

Input

The first line of the input contains an integer t (1 ≤ t ≤ 70 000): the number of test cases.

Each test case contain two lines. The first line contains two integers h and g (1 ≤ g < h ≤ 20). The second line contains n = 2^h-1 distinct positive integers a[1], a[2], …, a[n] (1 ≤ a[i] < 2^{20}). For all i from 2 to 2^h - 1, a[i] < a[\left ⌊{i/2}\right ⌋].

The total sum of n is less than 2^{20}.

Output

For each test case, print two lines.

The first line should contain one integer denoting the minimum sum after reducing the height of heap to g. The second line should contain 2^h - 2^g integers v_1, v_2, …, v_{2^h-2^g}. In i-th operation f(v_i) should be called.

Example

Input


2
3 2
7 6 3 5 4 2 1
3 2
7 6 5 4 3 2 1


Output


10
3 2 3 1
8
2 1 3 1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;
const double eps = 1e-7;
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) {
  for (const auto &x : xs)
    if (!(x >= 0 && x < t)) return false;
  return true;
}
int ceillog2(ll x) { return int(ceil(log2(x))); }
int floorlog2(ll x) { return int(floor(log2(x))); }
template <class T>
T reversed(T container) {
  reverse(container.begin(), container.end());
  return container;
}
template <class T>
void printv(const vector<T> &v) {
  for (const T &x : v) cout << x << " ";
  cout << "\n";
}
template <class T>
void printmx(const vector<vector<T>> &mx) {
  for (const vector<T> &v : mx) printv(v);
}
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) {
  ll m = (ll)sqrt((double)x);
  return m + (m * m <= x ? 0 : -1);
}
ll ceilsqrt(ll x) {
  ll m = (ll)sqrt((double)x);
  return m + (x <= m * m ? 0 : 1);
}
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) {
  if (n == 0)
    return m;
  else
    return gcd(n, m % n);
}
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
void f(int i, vi &a) {
  int l = i * 2 + 1;
  int r = i * 2 + 2;
  if (a.size() <= l) {
    a[i] = 0;
    return;
  }
  if (a[l] == 0 && a[r] == 0) {
    a[i] = 0;
  } else {
    if (a[l] > a[r]) {
      a[i] = a[l];
      f(l, a);
    } else {
      a[i] = a[r];
      f(r, a);
    }
  }
}
bool check(int i, const vi &a, int g) {
  int l = i * 2 + 1;
  int r = i * 2 + 2;
  if (a.size() <= l) return true;
  if (a[l] == 0 && a[r] == 0) {
    if (i < (1 << g) - 1)
      return false;
    else
      return true;
  } else {
    if (a[l] > a[r]) {
      return check(l, a, g);
    } else {
      return check(r, a, g);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  int t;
  cin >> t;
  for (int _ = 0; _ < int(t); _++) {
    int h, g;
    cin >> h >> g;
    vi a((1 << h) - 1);
    for (int i = 0; i < int((1 << h) - 1); i++) cin >> a[i];
    int r = 0;
    vi ans((1 << h) - (1 << g));
    for (int i = 0; i < int((1 << h) - (1 << g)); i++) {
      while (!check(r, a, g)) {
        r += 1;
      }
      f(r, a);
      ans[i] = r + 1;
    }
    ll sum = 0;
    for (int i = 0; i < int((1 << g) - 1); i++) {
      sum += a[i];
    }
    cout << sum << "\n";
    printv(ans);
  }
}