
#include<bits/stdc++.h>
using namespace std;
int main(){
int t,n,i;
cin>>t;
while(t--){
cin>>n;
int h[n],l[n],r[n];
stack<int> s;
memset(l,0,sizeof(l));
memset(r,0,sizeof(r));
for(i=0;i<n;i++){
cin>>h[i];
}
 for(i=0;i<n;i++){
	if(s.size()==0);
	else if(h[i]<s.top());
	else if(h[i]>=s.top()){
		while(s.size()!=0 && s.top()<h[i]){
			if(s.top()==h[i])
			l[i]+=1;
			s.pop();
		}
	}  
	s.push(h[i]);
}

 while(!s.empty())
s.pop();
for(i=n-1;i>=0;i--){
	if(s.size()==0);
	else if(h[i]<s.top());
	else if(h[i]>=s.top()){
		while(s.size()!=0 && s.top()<h[i]){
			if(s.top()==h[i])
			r[i]++;
			s.pop();
		}
	}
	s.push(h[i]);
}  
for(i=0;i<n;i++){
	cout<<l[i]+r[i]+ " ";
}
cout<<endl;  
}
return 0;
}
