← Home
package main

import (
	"bufio"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	nextToken := func() int {
		scanner.Scan()
		res, _ := strconv.Atoi(scanner.Text())
		return res
	}

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())

	for tc := 0; tc < t; tc++ {
		n := nextToken()
		k := nextToken()

		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = nextToken()
		}

		p := int64(1)
		j := 0
		for d := 0; d < k; d++ {
			for j < n && int64(a[j]-(j+1)) < p {
				j++
			}
			p += int64(j)
		}

		out.WriteString(strconv.FormatInt(p, 10))
		out.WriteByte('\n')
	}
}