#include <iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<iomanip>
#include<string.h>
#include<string>
#include<cmath>
#include<set>
#include<map>
#define ll long long
using namespace std;
struct
{
    ll id=0;
    ll num;
}a[105];
ll n;
void dg(int st,int ed)
{
    int i,j,maxx=0;
    if(st>ed||ed>n||st<1)
        return;
    for(i=st;i<=ed;i++)
    {
        a[i].id++;
        if(a[i].num>maxx){
            maxx=a[i].num;
            j=i;}
    }
    dg(st,j-1);
    dg(j+1,ed);
}
int main()
{
  ll t;
  cin>>t;
  while(t--)
  {

      ll i,j;

      cin>>n;
      ll maxx=0;
      for(i=1;i<=n;i++)
      {
          cin>>a[i].num;
          a[i].id=0;
          if(a[i].num>maxx){
            maxx=a[i].num;
          j=i;}
      }
      dg(1,j-1);
      dg(j+1,n);
      for(i=1;i<=n;i++)
        cout<<a[i].id<<" ";
      cout<<endl;
  }
  return 0;
}
	 		 	   		 	 				 			   	    	