Inverse Move-to-Front Transform

No attempts yetTime limit2sMemory limit256 MB

Problem

The Move-to-Front (MTF) transform is an encoding scheme that maps input data to a sequence of numbers. Entropy encoders often reach a better compression ratio on data that has passed through the MTF transform. The transform itself is simple. The scheme below is the MTF transform on a string made of lowercase letters only.

  1. Keep a list of the lowercase letters. The list starts in lexicographic order, so at the beginning it is [abcdefghijklmnopqrstuvwxyz].
  2. Read one character α\alpha from the string. Output the index of α\alpha in the list, then move α\alpha to the front of the list.
  3. Repeat step 2 until every character of the string has been read.

Applying the transform to the string hakka goes like this.

  1. The first character h has index 7 in [abcdefghijklmnopqrstuvwxyz]. Output 7, then move h to the front.
  2. The second character a has index 1 in [habcdefgijklmnopqrstuvwxyz]. Output 1, then move a to the front.
  3. The third character k has index 10 in [ahbcdefgijklmnopqrstuvwxyz]. Output 10, then move k to the front.
  4. The fourth character k has index 0 in [kahbcdefgijlmnopqrstuvwxyz]. Output 0, then move k to the front.
  5. The fifth character a has index 1 in [kahbcdefgijlmnopqrstuvwxyz]. Output 1, then move a to the front.

So the MTF transform maps hakka to the sequence (7,1,10,0,1)(7, 1, 10, 0, 1).

Write a program that inverts the MTF transform. Given a sequence (a1,,an)(a_1, \dots, a_n), compute the string ss that the MTF transform maps to (a1,,an)(a_1, \dots, a_n).

Input

The first line contains an integer TT, the number of test cases, with T50T \le 50.

Each test case consists of two lines. The first line contains a positive integer nn, the length of the sequence, with 1n1001 \le n \le 100. The second line contains the integers a1,,ana_1, \dots, a_n separated by blanks, with ai{0,1,,25}a_i \in \{0, 1, \dots, 25\} for every ii.

Output

For each test case, print on its own line the string ss that the MTF transform maps to (a1,,an)(a_1, \dots, a_n).