Number of matches
Submissions: 556   Accuracy:

26.22%

  Difficulty: Easy   Marks: 2

A knockout tournament is going on. A total of N number of players are participating. Each match will have two players. Every player has a distinct rating associated with him. The player with the more rating wins in a match. In one round, the 1st player will play a match against 2nd player, 3rd player will play a match against 4th player and so on. If there is odd number of players, last one will qualify to the next round without playing a match. Since it is a knockout tournament, whoever loses a match leaves the tournament. Your task is to find out the number of matches each player wins in the tournament. The tournament ends when there is only one player remaining in the end.

 

Input:
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. The first line contains N. In the next line are N space separated positive integers denoting the ratings of the N players.


Output:

Corresponding to each test case, in a new line, print the number of wins of each player with a single space between consecutive values.


Constraints:

1 ≤ T ≤ 100

1 ≤ N ≤ 103  

0 ≤ rating of player ≤ 105


Example:

Input

1
5
7 1 5 3 9

Output

3 1 2 1 1

Explanation:

players: 7 1 5 3 9

The first round: (7 has a match with 1), (5 has a match with 3), (9 has no matches automatically qualifies)

players: 7 5 9

The second round: (7 has a match with 5), (9 has no matches automatically qualifies)

players: 7 9

The third round: (7 has a match with 9).

The player with rating 7 played 3 matches. The player with rating 1 played 1 match. The player with rating 5 played 2 matches. The player with rating 3 played 1 match.  The player with rating 9 played 1 match. 

 

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Hemang Sarkar


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.