The peak that looks highest

Given each peak's apparent-highest peak ahead, assign integer heights matching all sightings and print the lexicographically smallest heights or Impossible.

Hard8GeometryBacktrackingMathNo attempts yetTime limit5sMemory limit512 MB

Problem

You are hiking along a mountain range. There is exactly one peak every kilometer and nothing in between, so the peaks are numbered 11 through NN in the order you walk them. On every peak you lie down to rest, look ahead, and one of the peaks in front of you looks like the highest one.

The peak that looks highest is not always the highest one. A taller peak can hide behind a nearer and lower peak, and when you look downhill a faraway peak can look higher than a close one.

Peak BB looks highest from peak AA when all three of these hold: BB is further down the road than AA, every peak between AA and BB is strictly below the line through the tops of AA and BB, and every peak beyond BB is on or below that line.

In the picture, peak 44 looks highest from peak 11 and from peak 33. From peak 22 you cannot see peak 44 at all, because peak 33 hides it, so peak 33 looks highest.

You do not know how high the peaks are, but you remember which peak looked highest from each of them. Assign heights that agree with that memory. You were lying down, so treat every sighting as taken from the ground level of the peak you were on.

Input

The first line has the number of test cases TT. Each test case takes two lines. The first line has NN, the number of peaks. Your walk starts on peak 11 and ends on peak NN. The second line has N1N - 1 numbers x1,x2,,xN1x_1, x_2, \dots, x_{N-1}, where xix_i is the index of the peak that looked highest from peak ii. Peak NN is the last one, so it records nothing.

Output

For each test case print one line in the form Case #n: y1 y2 ... yN, where n is the test case number starting from 1 and yiy_i is the height of peak ii. Every height must be an integer between 00 and 10910^9, inclusive.

Several assignments of heights can agree with the same memory, so print the lexicographically smallest one. A sequence yy is lexicographically smaller than a sequence zz when yy holds the smaller value at the first position where the two differ.

If no assignment of heights agrees with the memory, print Case #n: Impossible instead.

Constraints

  • 1T301 \le T \le 30
  • 2N102 \le N \le 10
  • i<xiNi < x_i \le N