Extreme Escalator Pogo (Small)

Starting from the best blue step on a circular escalator, pick jump heights that change by at most one to maximize the height reached before landing on red.

Medium7GraphBFSBrute forceNo attempts yetTime limit5sMemory limit512 MB

Problem

Robbit Downey Hopper invented the dangerous sport of Extreme Escalator Pogo. It really is dangerous, so do not try it at home even if you own an escalator. Do not try it anywhere.

Extreme Escalator Pogo needs two things: a jumping device called a pogo stick, and a fast escalator with NN steps that rise at a constant speed. Some of the steps are blue and the rest are red. Robbit starts by jumping onto a blue step in the middle of the escalator with his pogo stick. From then on he keeps bouncing straight up while the steps move underneath him. He may land only on blue steps. The moment he lands on a red step he is out, and his challenger Leepie Froggison gets her turn to jump. Whoever reaches the greatest height wins.

After touching his first blue step, Robbit's first jump always has height 1 and takes him to the very next step. (That step had better be blue.) On every jump except the first one he picks one of three options:

  • dampen the jump and decrease the height by 1,
  • jump to the same height as the current jump,
  • amplify the jump and increase the height by 1.

A jump of height HH takes exactly as long as HH escalator steps need to pass under Robbit, so a jump of height HH from step ii lands on the step that sits HH positions after step ii. A jump of height 0 is not allowed, and the height has no upper bound. The steps run on a loop that cycles forever.

The height of a jump still counts when that jump ends on a red step. Given NN and the colour of every step, find the greatest height Robbit can reach when he picks the best starting step and the best sequence of jumps.

Input

The first line gives the number of test cases TT. Each of the next TT lines contains an integer NN, then an integer KK, then KK integers in the range 1 to NN that list the blue steps. Every other step is red. The step after step NN is step 1.

Limits

  • 1T1001 \le T \le 100
  • 3N103 \le N \le 10
  • 1KN1 \le K \le N
  • The KK blue step numbers are distinct and given in increasing order.

Output

For each test case print one line in the form Case #x: H, where xx is the test case number starting from 1 and HH is the greatest height Robbit can reach. If the height has no upper bound, print infinity in place of HH.

Hint

In the first case of the first example, N=4N = 4 and steps 2 and 3 are blue. Robbit starts on step 2, jumps with height 1 onto step 3, then amplifies to height 2 and lands two positions later on the red step 1. The greatest height reached this way is 2.

In the second case the best plan starts on step 5 and goes to step 6 (height 1), step 8 (height 2), step 1 (height 3), step 5 (height 4), and finally step 10 (height 5), which is red.

In the third case N=3N = 3 and steps 1 and 2 are blue. Robbit starts on step 1 and can keep jumping forever, so he reaches any height he wishes.