// Timothy Buzzelli
// 2/21/2017
// Solution (with data verification) to 2017 FHSPS Playoff Question: Bonus Points.

import java.util.*;

public class bonus_buzzelli {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        // Get input and check it.
        String line = in.nextLine();
        String[] tokens = line.split(" ");
        if(tokens.length != 1) {
            System.err.println("Data invalid on input of v! Incorrect number of tokens!");
        }
        int v = Integer.parseInt(tokens[0]);
        if(v <= 0 || v > 100) {
            System.err.printf("v is out of bounds. It is %d when it should be in the range [1, 100]!\n", v);
        }
        
        // Process cases.
        for(int ci = 0; ci < v; ci++) {
        	
        	// Get input.
            line = in.nextLine();
            tokens = line.split(" ");
            if(tokens.length != 2) {
                System.err.println("Data invalid on input for n and c! Incorrect number of tokens!");
            }
            int n = Integer.parseInt(tokens[0]);
            int c = Integer.parseInt(tokens[1]);
            
            // Check bounds.
            if(n <= 0 || n > 100) {
                System.err.printf("n is out of bounds. It is %d when it should be in the range [1, 100]!\n", n);
            }
            
            if(c < 10 || c > 1000 || c % 2 == 1) {
                System.err.printf("c is out of bounds. It is %d when it should be in the range [10, 1,000] and be even!\n", c);
            }
            
            // Get scores on each levle.
            int[] arr = new int[n];
            line = in.nextLine();
            tokens = line.split(" ");
            if(tokens.length != n) {
                System.err.println("Data invalid on input for the scores! Incorrect number of tokens!");
            }
            
            // Check values.
            for(int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(tokens[i]);
                if(arr[i] < 0 || arr[i] > 100000) {
                    System.err.printf("score is out of bounds. It is %d when it should be in the range [0, 100,000]\n", arr[i]);
                }
            }
            
            // Solve it!
            int score = 0;
            for(int i = 0; i < n; i++) {
                score += arr[i];
                while(c * 2 <= score) c *= 2;
                if(score >= c) {
                    score += c / 2;
                    c *= 2;
                }
            }
            
            System.out.println(score);
        }
    }
    
}
