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:
public class Main {
	public static void main(String[] args) {
		new Main();
	}

	static class FastScanner {
		    private final java.io.InputStream in = System.in;
		    private final byte[] buffer = new byte[1024];
		    private int ptr = 0;
		    private int buflen = 0;
		    private boolean hasNextByte() {
		        if (ptr < buflen) {
		            return true;
		        }else{
		            ptr = 0;
		            try {
		                buflen = in.read(buffer);
		            } catch (java.io.IOException e) {
		                e.printStackTrace();
		            }
		            if (buflen <= 0) {
		                return false;
		            }
		        }
		        return true;
		    }
		    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
		    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
		    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
		    public String next() {
		        if (!hasNext()) throw new java.util.NoSuchElementException();
		        StringBuilder sb = new StringBuilder();
		        int b = readByte();
		        while(isPrintableChar(b)) {
		            sb.appendCodePoint(b);
		            b = readByte();
		        }
		        return sb.toString();
		    }
		    public long nextLong() {
		        if (!hasNext()) throw new java.util.NoSuchElementException();
		        long n = 0;
		        boolean minus = false;
		        int b = readByte();
		        if (b == '-') {
		            minus = true;
		            b = readByte();
		        }
		        if (b < '0' || '9' < b) {
		            throw new NumberFormatException();
		        }
		        while(true){
		            if ('0' <= b && b <= '9') {
		                n *= 10;
		                n += b - '0';
		            }else if(b == -1 || !isPrintableChar(b)){
		                return minus ? -n : n;
		            }else{
		                throw new NumberFormatException();
		            }
		            b = readByte();
		        }
		    }
		    public int nextInt() {
		        long nl = nextLong();
		        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		        return (int) nl;
		    }
		    public double nextDouble() { return Double.parseDouble(next());}
		}

	public Main() {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			FastScanner fs = new FastScanner();
			int t = fs.nextInt();
			while(t --> 0) {
				int h = (1 << fs.nextInt()) - 1, g = (1 << fs.nextInt()) - 1;
				int[] a = new int[h + 1 << 1];
				for (int i = 1;i <= h;++ i) a[i] = fs.nextInt();
				java.util.PriorityQueue<Integer> set = new java.util.PriorityQueue<Integer>();
				boolean[] isOperate = new boolean[a.length];
				for (int i = h;i > 0;-- i) {
					int left = i << 1, right = i << 1 | 1;
					if (i > g) isOperate[i] = true;
					else if (a[left] > a[right] && isOperate[left]) isOperate[i] = true;
					else if (a[left] <= a[right] && isOperate[right]) isOperate[i] = true;
					if (isOperate[i]) set.add(i);
				}
				java.util.List<Integer> ans = new java.util.ArrayList<>();
				int[] operate = new int[30];
				int size = 0;
				while(h != g) {
					int tmp = set.poll();
					if (!isOperate[tmp]) continue;
					ans.add(tmp);
					-- h;
					do {
						int left = tmp << 1, right = tmp << 1 | 1;
						operate[size ++] = tmp;
						if (a[left] == 0 && a[right] == 0) {
							a[tmp] = 0;
							break;
						}
						if (a[left] > a[right]) {
							a[tmp] = a[left];
							tmp = left;
						} else {
							a[tmp] = a[right];
							tmp = right;
						}
					} while(true);
					while(size > 0) {
						tmp = operate[-- size];
						int left = tmp << 1, right = tmp << 1 | 1;
						boolean last = isOperate[tmp];
						isOperate[tmp] = tmp > g
								|| a[left] > a[right] && isOperate[left]
								|| a[left] <= a[right] && isOperate[right];
						if (a[tmp] == 0) isOperate[tmp] = false;
						if (size != 0 && last == isOperate[tmp]) continue;
						if (isOperate[tmp]) set.add(tmp);
					}
				}
				long sum = 0;
				for (int i : a) sum += i;
				System.out.println(sum);
				System.out.println(String.join(" ", ans.stream().map(i -> String.valueOf(i)).toArray(String[]::new)));
			}
		}
	}
}