Vanishing Numbers (Small)

Sort each decimal by the round it is removed from the Cantor middle-third process, placing numbers that never vanish last.

Medium5MathSortingNo attempts yetTime limit5sMemory limit512 MB

Problem

There is a pool of numbers, each of them a decimal fraction from the interval (0,1)(0, 1). In the first round the middle third of (0,1)(0, 1) disappears, and every number that falls into it drops out of the pool. In each later round the middle third of every remaining interval disappears. Round 1 removes [1/3,2/3][1/3, 2/3], round 2 removes [1/9,2/9][1/9, 2/9] and [7/9,8/9][7/9, 8/9], and so on. The endpoints of a removed interval are removed with it.

Sort the pool by the round in which each number disappears. Numbers that never disappear go last. When two numbers disappear in the same round, print the smaller one first. When the same number occurs several times in the pool, print it once for each occurrence.

Input

The first line contains TT, the number of test cases. Each test case starts with a line holding an integer NN, followed by NN numbers, one per line. Each number starts with "0." and continues with one or more decimal digits. Every number is greater than zero and has no trailing zero.

Limits

  • 1T1001 \le T \le 100
  • 1N1001 \le N \le 100
  • Each number has at most 12 digits after the decimal point.
  • Each number either disappears within the first 1000 rounds or never disappears.

Output

For each test case, print the line "Case #x:", where xx is the number of the test case, starting with 1. After that line, print the NN numbers of that pool, one per line, in the order they disappear. Print each number exactly as it was written in the input.

Hint

In case #1 of the sample, 0.5 disappears in round 1 because it falls into [1/3,2/3][1/3, 2/3]. After round 1 two intervals are left, (0,1/3)(0, 1/3) and (2/3,1)(2/3, 1), and 0.12 disappears in round 2 because it falls into [1/9,2/9][1/9, 2/9]. In case #2 neither 0.1 nor 0.9 ever disappears, so both come last, the smaller one first.