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;
static int sc_ret = 0;
struct pt_nl {};
struct sc {
  sc& operator>>(char& v) {
    v = sc_ret = getchar();
    return *this;
  }
  sc& operator>>(int& v) {
    sc_ret = scanf("%d", &v);
    return *this;
  }
  sc& operator>>(unsigned& v) {
    sc_ret = scanf("%u", &v);
    return *this;
  }
  sc& operator>>(double& v) {
    sc_ret = scanf("%lf", &v);
    return *this;
  }
  sc& operator>>(char* v) {
    sc_ret = scanf("%s", v);
    return *this;
  }
  sc& operator>>(string& v) {
    sc_ret = (bool)(cin >> v);
    return *this;
  }
  sc& operator>>(long long& v) {
    sc_ret = read(v);
    return *this;
  }
  sc& ch(char& v) {
    sc_ret = scanf(" %c", &v);
    return *this;
  }
  sc& gets(char* v) {
    sc_ret = fgets(v, INT_MAX, stdin) != 0;
    v[strlen(v) - 1] = 0;
    return *this;
  }
  operator bool() const { return sc_ret > 0; }
  template <typename T>
  int read(T& v) {
    T x = 0, k = 1;
    int c = getchar();
    while (c < '0' || c > '9') {
      if (c == '-') k = -1;
      c = getchar();
    }
    while (c >= '0' && c <= '9')
      x = (x << 3) + (x << 1) + (c - 48), c = getchar();
    v = x * k;
    return c;
  }
};
struct pr {
  pr& ln() {
    putchar('\n');
    return *this;
  }
  pr& operator<<(const pt_nl& nl) {
    putchar('\n');
    return *this;
  }
  pr& operator<<(char v) {
    putchar(v);
    return *this;
  }
  pr& operator<<(int v) {
    write(v);
    return *this;
  }
  pr& operator<<(double v) {
    printf("%.2f", v);
    return *this;
  }
  pr& operator()(const char* fmt, double v) {
    printf(fmt, v);
    return *this;
  }
  pr& operator<<(const char* v) {
    printf("%s", v);
    return *this;
  }
  pr& operator<<(string v) {
    printf("%s", v.c_str());
    return *this;
  }
  pr& operator<<(long long v) {
    write(v);
    return *this;
  }
  template <typename T>
  void write(T v) {
    int cnt = 0;
    char c[23];
    if (v == 0) {
      putchar('0');
      return;
    }
    if (v < 0) putchar('-'), v = -v;
    while (v) c[++cnt] = (v % 10) + 48, v /= 10;
    while (cnt > 0) putchar(c[cnt--]);
  }
  template <typename T>
  void ln(T* arr, int size) {
    if (size > 0) {
      (*this) << arr[0];
      for (int i = 1; i < size; ++i) {
        putchar(' ');
        (*this) << arr[i];
      }
      putchar('\n');
    }
  }
  template <typename T>
  void muln(T* arr, int size) {
    for (int i = 0; i < size; ++i) {
      (*this) << arr[i];
      putchar('\n');
    }
  }
};
const int inf = 0x3f3f3f3f;
const int mod1e9 = 1000000007;
const int mod998 = 998244353;
const int mod = mod1e9;
const int maxn = 2000000 + 10;
int dfs_rm = 0, rm_val;
int dfs(vector<int>& v, vector<int>& vc, int p, int& cp) {
  int r = v[p];
  int lp = p * 2, rp = p * 2 + 1;
  --vc[p];
  if (lp >= v.size() || v[lp] == 0 && v[rp] == 0) {
    v[p] = 0;
    return r;
  }
  if (v[lp] > v[rp]) {
    if (vc[lp] <= 0) {
      int cp_ = 1;
      rm_val = v[rp];
      dfs(v, vc, dfs_rm = rp, cp_);
      cp = 0;
      return r;
    } else {
      int r = dfs(v, vc, lp, cp);
      if (cp) v[p] = r;
    }
  } else {
    if (vc[rp] <= 0) {
      int cp_ = 1;
      rm_val = v[lp];
      dfs(v, vc, dfs_rm = lp, cp_);
      cp = 0;
      return r;
    } else {
      int r = dfs(v, vc, rp, cp);
      if (cp) v[p] = r;
    }
  }
  return r;
}
void Main(int ca) {
  int n, m;
  sc() >> n >> m;
  vector<int> v, vc;
  v.resize(1 << n);
  vc.resize(1 << n);
  for (int i = 1; i < v.size(); i++) {
    sc() >> v[i];
  }
  for (int i = (1 << n) - 1, a = 1 << m; i > 0; i--) {
    vc[i] = i >= a;
    if (i * 2 < v.size()) vc[i] += vc[i * 2];
    if (i * 2 + 1 < v.size()) vc[i] += vc[i * 2 + 1];
  }
  vector<int> pos;
  vector<int> rv;
  for (int i = (1 << n), a = 1 << m; i > a; i--) {
    int cp = 1;
    dfs_rm = 1;
    rm_val = v[1];
    dfs(v, vc, 1, cp);
    pos.push_back(dfs_rm);
    rv.push_back(rm_val);
  }
  long long sum = 0;
  for (int i = 1, a = 1 << m; i < a; i++) {
    sum += v[i];
  }
  pr() << sum << pt_nl();
  pr().ln(&*pos.begin(), pos.size());
}
int main() {
  int t, c = 0;
  sc() >> t;
  while (t--) Main(++c);
  return 0;
}