Under construction

Still being built. Things may change

The Riddle

Time limit1sMemory limit128 MB

Summary
Find the minimum prefix length of a coin sequence so that all values from 1 to K are achievable as subset sums, using the classic greedy reachable-range extension, or report -1.
Level

Medium4 of 10

Topics
Greedy, Array, Prefix sum
Solved
No attempts yet

Problem

Eleonora's grandmother Sercha loves posing math riddles to her grandchildren. On the family's last trip she gave this one:

"Suppose a shop sells items priced from 11 to KK. I have NN coins whose denominations, in order, are A1,A2,…,ANA_1, A_2, \ldots, A_N. I am old and want to carry as few coins as possible. If I pick the coins up one by one starting from A1A_1, how many coins from the front must I take so that, using subsets of the coins I have taken, I can pay every price from 11 to KK exactly?"

Eleonora answered within seconds and thought, "Basic algorithms like this are easy now!"

Help Eleonora. Taking the coins from the front in the given order, find the smallest number of coins that must be taken so that every amount from 11 to KK can be formed as a subset sum of the taken coins. If this is impossible even after taking all NN coins, output −1-1.

Input

The first line contains the number of test cases TT.

For each test case, the first line contains two integers NN and KK (N≤100000N \le 100000, K≤1000000K \le 1000000). The second line contains the NN coin denominations A1,A2,…,ANA_1, A_2, \ldots, A_N in order, separated by spaces (Ai≤100000A_i \le 100000).

Output

For each test case, print on its own line the minimum number of coins that must be taken from the front so that every price from 11 to KK can be paid as a subset sum of the taken coins. If it is impossible even after taking all NN coins, print −1-1.

Examples3

  1. Example 1

    Input
    3
    7 10
    1 2 3 4 5 6 7
    3 3
    2 4 1
    3 6
    3 1 4
    
    Expected output
    4
    3
    -1
    
  2. Example 2

    Input
    1
    1 1
    1
    
    Expected output
    1
    
  3. Example 3

    Input
    1
    2 1
    2 1
    
    Expected output
    2