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 JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.util.Objects;
import java.io.UncheckedIOException;
import java.nio.charset.Charset;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        LightWriter out = new LightWriter(outputStream);
        CDrazilLikesHeap solver = new CDrazilLikesHeap();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDrazilLikesHeap {
        private static final CDrazilLikesHeap.Heap FAIL = new CDrazilLikesHeap.Heap(-1, -1, false);

        public void solve(int testNumber, LightScanner in, LightWriter out) {
            int testCases = in.ints();
            for (int testCase = 0; testCase < testCases; testCase++) {
                // INITIALIZE ALL
                int h = in.ints(), h2 = (1 << h) - 1, g = in.ints(), g2 = (1 << g) - 1;
                long sum = 0;
                int[] ans = new int[h2 - g2];
                CDrazilLikesHeap.Heap[] a = new CDrazilLikesHeap.Heap[h2];
                for (int i = 0; i < h2; i++) {
                    a[i] = new CDrazilLikesHeap.Heap(i, in.ints(), i >= g2);
                    sum += a[i].x;
                }
                for (int i = 0; i < h2 / 2; i++) {
                    a[i].l = a[i * 2 + 1];
                    a[i].r = a[i * 2 + 2];
                }


                PriorityQueue<CDrazilLikesHeap.Heap> q = new PriorityQueue<>(Comparator.comparing(elm -> elm.x));
                q.offer(a[0]);
                for (int t = 0; t < h2 - g2; t++) {
                    //System.out.println(q);
                    CDrazilLikesHeap.Heap peek = Objects.requireNonNull(q.poll());
                    int d = peek.x;
                    while (peek.f(q) == FAIL) {
                        peek = Objects.requireNonNull(q.poll());
                        d = peek.x;
                    }
                    ans[t] = peek.index;
                    sum -= d;
                    q.offer(peek);
                }
                out.ans(sum).ln();
                for (int t = 0; t < h2 - g2; t++) out.ans(ans[t] + 1);
                out.ln();
            }
        }

        private static class Heap {
            int index;
            int x;
            CDrazilLikesHeap.Heap l;
            CDrazilLikesHeap.Heap r;
            boolean removable;

            Heap(int index, int x, boolean removable) {
                this.index = index;
                this.x = x;
                this.removable = removable;
            }

            CDrazilLikesHeap.Heap f(PriorityQueue<CDrazilLikesHeap.Heap> q) {
                if (l == null && r == null) {
                    return this.removable ? null : FAIL;
                } else if (l == null) {
                    if (pickR(q)) return this;
                } else if (r == null || l.x > r.x) {
                    if (pickL(q)) return this;
                } else {
                    if (pickR(q)) return this;
                }
                return FAIL;
            }

            boolean pickR(PriorityQueue<CDrazilLikesHeap.Heap> q) {
                int t = r.x;
                CDrazilLikesHeap.Heap nr = r.f(q);
                if (nr == FAIL) {
                    this.removable = false;
                    if (l != null) q.offer(l);
                    return false;
                }
                x = t;
                r = nr;
                return true;
            }

            boolean pickL(PriorityQueue<CDrazilLikesHeap.Heap> q) {
                int t = l.x;
                CDrazilLikesHeap.Heap nl = l.f(q);
                if (nl == FAIL) {
                    this.removable = false;
                    if (r != null) q.offer(r);
                    return false;
                }
                x = t;
                l = nl;
                return true;
            }

            public String toString() {
                return "Heap{" +
                        "index=" + index +
                        '}';
            }

        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }

    static class LightWriter implements AutoCloseable {
        private final Writer out;
        private boolean autoflush = false;
        private boolean breaked = true;

        public LightWriter(Writer out) {
            this.out = out;
        }

        public LightWriter(OutputStream out) {
            this(new OutputStreamWriter(new BufferedOutputStream(out), Charset.defaultCharset()));
        }

        public LightWriter print(char c) {
            try {
                out.write(c);
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter print(String s) {
            try {
                out.write(s, 0, s.length());
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter ans(String s) {
            if (!breaked) {
                print(' ');
            }
            return print(s);
        }

        public LightWriter ans(long l) {
            return ans(Long.toString(l));
        }

        public LightWriter ans(int i) {
            return ans(Integer.toString(i));
        }

        public LightWriter ln() {
            print(System.lineSeparator());
            breaked = true;
            if (autoflush) {
                try {
                    out.flush();
                } catch (IOException ex) {
                    throw new UncheckedIOException(ex);
                }
            }
            return this;
        }

        public void close() {
            try {
                out.close();
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

    }
}