Haircut Queue

Find which of B barbers with fixed cutting times serves the Nth customer when each free barber takes the next waiting customer.

Medium5Binary searchMathInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

A long line has formed outside a fashionable barber shop, and you are standing in it. The shop has BB barbers on duty, numbered 1 through BB. The kkth barber always takes exactly MkM_k minutes to cut one customer's hair, and can only cut one customer's hair at a time. As soon as a barber finishes, that barber takes the next customer.

The customer at the head of the line goes to the available barber with the lowest number. If no barber is available, that customer waits until at least one becomes available.

You are the NNth person in line, and the shop has just opened. Find the number of the barber who cuts your hair.

Input

The first line contains the number of test cases TT. Each test case then follows on two lines. The first line of a test case contains two space-separated integers BB and NN, the number of barbers and your place in line. The customer at the head of the line is number 1, the next one is number 2, and so on. The second line contains M1,M2,,MBM_1, M_2, \dots, M_B, separated by spaces.

Limits

  • 1T1001 \le T \le 100
  • 1N1091 \le N \le 10^9
  • 1B51 \le B \le 5
  • 1Mk251 \le M_k \le 25

Output

For each test case, print one line in the format Case #x: y, where xx is the test case number starting from 1 and yy is the number of the barber who cuts your hair.

Note

Take the case B=2B = 2, N=4N = 4, M1=10M_1 = 10, M2=5M_2 = 5. The moment the shop opens, the first customer can choose between barbers 1 and 2, so she takes the lower number, barber 1. The second customer goes straight to barber 2. The third customer waits, because no barber is free. After 5 minutes barber 2 finishes the second customer and takes the third one. At minute 10 barbers 1 and 2 finish together, and you are next in line, so you choose between them and take barber 1.