Problem: A permutation — is a sequence of length n integers from 1 to n, in which all the numbers occur exactly once. For example, [1], [3, 5, 2, 1, 4], [1, 3, 2] — permutations, and [2, 3, 2], [4, 3, 1], [0] — no.

Polycarp was recently gifted a permutation a[1 ... n] of length n. Polycarp likes trees more than permutations, so he wants to transform permutation a into a rooted binary tree. He transforms an array of different integers into a tree as follows: 

  * the maximum element of the array becomes the root of the tree; 
  * all elements to the left of the maximum — form a left subtree (which is built according to the same rules but applied to the left part of the array), but if there are no elements to the left of the maximum, then the root has no left child; 
  * all elements to the right of the maximum — form a right subtree (which is built according to the same rules but applied to the right side of the array), but if there are no elements to the right of the maximum, then the root has no right child. 



For example, if he builds a tree by permutation a=[3, 5, 2, 1, 4], then the root will be the element a_2=5, and the left subtree will be the tree that will be built for the subarray a[1 ... 1] = [3], and the right one — for the subarray a[3 ... 5] = [2, 1, 4]. As a result, the following tree will be built: 

<image> The tree corresponding to the permutation a=[3, 5, 2, 1, 4].

Another example: let the permutation be a=[1, 3, 2, 7, 5, 6, 4]. In this case, the tree looks like this: 

<image> The tree corresponding to the permutation a=[1, 3, 2, 7, 5, 6, 4].

Let us denote by d_v the depth of the vertex a_v, that is, the number of edges on the path from the root to the vertex numbered a_v. Note that the root depth is zero. Given the permutation a, for each vertex, find the value of d_v.

Input

The first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.

The first line of each test case contains an integer n (1 ≤ n ≤ 100) — the length of the permutation.

This is followed by n numbers a_1, a_2, …, a_n — permutation a.

Output

For each test case, output n values — d_1, d_2, …, d_n.

Example

Input


3
5
3 5 2 1 4
1
1
4
4 3 1 2


Output


1 0 2 3 1 
0 
0 1 3 2 

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;

#define seti set<int>
#define setl set<long long >
#define loop(j,n) for(int i=j;i<n;i++)
#define ll long long
#define all(a) a.begin(),a.end()
#define ts(i)  to_string(i)
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define MAX  200001
int INF=1e9;
//##########################################################
ll countfactor(ll n)
{
	ll count = 0;
	ll t = 0;
	ll num = 0;
	for (ll i = 2 ; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			ll temp = n;
			while (temp % i == 0)
			{
				temp = temp / i;
				count++;
			}
		}
		if (count > t)
		{
			num = i;
		}
		t = max(t, count);
		count = 0;
	}
	return num;
}

//#######################
int binomialCoeff(int n, int k)
{
	//base case
	if (k > n)
		return 0;
	if (k == 0 || k == n)
		return 1;

	// Recur
	return binomialCoeff(n - 1, k - 1)
	       + binomialCoeff(n - 1, k);

}
//###################################
ll gcd(ll x,ll y)
{
	if(y==0)
	return x;
		
	return gcd(y,x%y);
}
////#############################
bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
//######################
int N=1e9; 
vector<int>pr;
void sieve()
{	
	 bool prime[N+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=N; p++) 
    { 
       
        if (prime[p] == true) 
        { 
            
            for (int i=p*p; i<=N; i += p) 
                prime[i] = false; 
        } 
    } 
	for(int i=2;i<=N;i++)
	{
		if(prime[i]==true)
		pr.pb(i);
	}	
}


//########## SEGMENTREE_SUM_START ####################

//########## SEGMENT_TREE_END ####################


ll power(ll x, unsigned ll y)
{
    ll res = 1;     // Initialize result
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = res*x;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = x*x;  // Change x to x^2
    }
    return res;
}


bool check(string expr) 
{   
    stack<char> s; 
    char x; 
  
    // Traversing the Expression 
    for (int i = 0; i < (int)expr.length(); i++)  
    { 
        if (expr[i] == '(' || expr[i] == '['
            || expr[i] == '{')  
        { 
            // Push the element in the stack 
            s.push(expr[i]); 
            continue; 
        } 
  
        // IF current current character is not opening 
        // bracket, then it must be closing. So stack 
        // cannot be empty at this point. 
        if (s.empty()) 
            return false; 
  
        switch (expr[i]) { 
        case ')': 
              
            // Store the top element in a 
            x = s.top(); 
            s.pop(); 
            if (x == '{' || x == '[') 
                return false; 
            break; 
  
        case '}': 
  
            // Store the top element in b 
            x = s.top(); 
            s.pop(); 
            if (x == '(' || x == '[') 
                return false; 
            break; 
  
        case ']': 
  
            // Store the top element in c 
            x = s.top(); 
            s.pop(); 
            if (x == '(' || x == '{') 
                return false; 
            break; 
        } 
    } 
  
    // Check Empty Stack 
    return (s.empty()); 
} 



vector<int>T(1000);
vector<pair<int,int>>p;
void  divide(vector<int>A,int left,int right,int d)
{
	if(left<0 || right>=A.size())
	{
		return ;
	}
	if(left>right)
	{
		return ;
	}
	int mx=-1;
	int index=-1;
	for(int i=left;i<=right;i++)
	{
		if(mx<A[i])
		{
			index=i;
			mx=max(mx,A[i]);
		}
	}

	T[index]=d;
	divide(A,left,index-1,d+1);
	//T.push_back(l);
	divide(A,index+1,right,d+1);
	//T.push_back(r);
	//p.push_back({l,r});
	return ;

}
void test_case()
{	
	int n;
	cin>>n;
	vector<int>A(n);
	int mx=-1;
	for(int i=0;i<n;i++)
	{
		cin>>A[i];
		mx=max(mx,A[i]);
	}
	divide(A, 0,n-1,0);
	//cout<<index<<endl;
	/*for(int i=0;i<T.size();i++)
	{
		cout<<T[i]<<" ";
	}
	cout<<endl;*/
	/*for(int i=p.size()-1;i>=0;i--)
	{
		cout<<p[i].first<<" "<<p[i].second<<" ";
		cout<<"\n";
	}*/
	for(int i=0;i<n;i++)
	{
		cout<<T[i]<<" ";
	}
	cout<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t;
	cin>>t;
	while(t--)
	test_case();
	#ifndef ONLINE_JUDGE
	cout<<(double_t)clock()/CLOCKS_PER_SEC<<"sec"<<endl;
	#endif
}