Fence

Pick the fewest boards from the given lengths of at most 100 so they sum to exactly L up to 1e18, or report IMPOSSIBLE.

Medium7Dynamic programmingNumber theoryGreedyNo attempts yetTime limit5sMemory limit512 MB

Problem

You are building a very long fence. The site is already chosen, so all that is left is collecting the material.

The hardware stores nearby sell wooden boards in several lengths, and you can buy as many boards of each length as you want. To waste nothing, the total length of the boards you buy has to be exactly the length of the fence.

Given the length of the fence and the board lengths on sale, find the minimum number of boards you have to buy so that their total length is exactly right.

Be careful: the fence is going to be very long.

Input

The first line contains the number of test cases TT. The TT test cases follow.

Each test case consists of two lines. The first line contains the total length of the fence LL and the number of different board lengths on sale NN, separated by a space. The second line contains the board lengths B1,B2,,BNB_1, B_2, \dots, B_N, separated by spaces.

Limits

  • 1T501 \le T \le 50
  • 1010L101810^{10} \le L \le 10^{18}
  • 1N1001 \le N \le 100
  • 1Bi1001 \le B_i \le 100

Output

For each test case, print one line in the form "Case #x: M", where xx is the test case number starting from 1 and MM is as follows.

  • If you can buy one or more boards whose total length is exactly LL, then MM is the minimum number of boards needed to do that.
  • Otherwise MM is the string "IMPOSSIBLE".

Hint

In the first case of the example, the best purchase is 2 boards of length 23, 5 boards of length 51, and 99999997 boards of length 100. Buying 100000001 boards of length 100 gives a total greater than LL, and that is not allowed.

In the second case of the example, only even lengths can be reached.