Help BerLine

아직 제출이 없습니다시간 제한5초메모리 제한512 MB

문제

Very soon, the new cell phone services provider "BerLine" will begin its work in Berland!

The start of customer service is planned along the main street of the capital. There are nn base stations that are already installed. They are located one after another along the main street in the order from the 11-st to the nn-th from left to right. 

Currently, all these base stations are turned off. They will be turned on one by one, one base station per day, according to some permutation p=\[p_1,p_2,,p_n]p = \[p\_1, p\_2, \dots, p\_n] (1p_in 1 \le p\_i \le n), where p_ip\_i is the index of a base station that will be turned on on the ii-th day. Thus, it will take nn days to turn on all base stations.

Each base station is characterized by its operating frequency f_if\_i --- an integer between 11 and 2424, inclusive.

There is an important requirement for operating frequencies of base stations. Consider an arbitrary moment in time. For any phone owner, if we consider all base stations turned on in the access area of their phone, then in this set of base stations there should be at least one whose operating frequency is unique among the frequencies of these stations. Since the power of the phone and the position are not known in advance, this means that for any nonempty subsegment of turned on base stations, at least one of them has to have the operating frequency that is unique among the stations of this subsegment.

For example, let's take a look at a case of n=7n = 7, all nn stations are turned on, and their frequencies are equal to f=\[1,2,1,3,1,2,1]f = \[1, 2, 1, 3, 1, 2, 1]. Consider any subsegment of the base stations --- there is a base station with a unique frequency within this subsegment. However, if f=\[1,2,1,2,3,2,1]f = \[1, 2, 1, 2, 3, 2, 1], then there is no unique frequency on the segment \[1,2,1,2]\[1, 2, 1, 2] from the index 11 to the index 44, inclusive.

Your task is to assign a frequency from 11 to 2424 to each of nn base stations in such a way that the frequency requirement is met at every moment. Remember that the base stations are turned on in the order of the given permutation pp.

입력

The first line of the input contains an integer tt (1t501 \le t \le 50) --- the number of test cases in the input. Then tt test case descriptions follow.

The first line of a test case contains an integer nn (1n8,500 1 \le n \le 8\\,500) --- the number of "BerLine" base stations.

The following line contains nn distinct integers p_1,p_2,,p_np\_1, p\_2, \dots, p\_n (1p_in1 \le p\_i \le n) --- the order in which the base stations are turned on, i. e. on the ii-th day the base station with the index p_ip\_i is turned on.

It is guaranteed that a correct answer exists for all test cases in the input.

출력

Print exactly tt lines, where the jj-th line contains the answer for the jj-th test case in the input. Print the required frequencies f_1,f_2,,f_nf\_1, f\_2, \dots, f\_n (1f_i241 \le f\_i \le 24). If there are several possible answers, print any of them.

힌트

In the first test case n=3n = 3 and p=\[1,3,2]p = \[1, 3, 2]. The base stations can be assigned frequencies \[1,3,2]\[1, 3, 2].

  • Day 1: only the base station 11 is turned on, its frequency is 11.
  • Day 2: the base stations 11 and 33 are turned on, their frequencies are \[1,2]\[1, 2].
  • Day 3: all base stations are turned on, their frequencies are \[1,3,2]\[1, 3, 2] (in the direction along the street).

On each day, each nonempty subsegment of turned on base stations has a base station with a unique frequency among this subsegment. It can be shown that three distinct frequencies are necessary in this test case.