11947 - Step by step   

Description

Niflheimr creates a special robot, which can only take steps with some special length.

Now given lengths of those steps and the target location, please tell Niflheimr the minimum steps the robot has to take to reach the target. The robot can choose different step lengths each time while taking a new step.

The robot is located at 0 initially. Note that the robot can go backward.

Hint: Try to memorize locations that has been computed before. std::queue and std::set may be useful.

Input

First line of input contains an integer T, denotng the number of testcases.

Each testcases consists of two lines:

First line of each testcase contains two integer N, D, denoting the number of steps the robot can take and the target location, respectively.

Second line of each testcase contains N distinct integers, denoting the lengths of steps the robot can take.

It is guaranteed that:

  • 1 <= T <= 5
  • 1 <= N <= 10
  • 1 <= D <= 1000
  • 1 <= length of each step <= 2000

 

Output

For each testcase, print one integer x in a single line, representing the minimum steps the robot has to take to reach the target. If the robot can't reach the target, print -1.

Sample Input  Download

Sample Output  Download

Tags




Discuss