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 

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;


public class N702 {
	static PrintWriter out;
	static Scanner sc;
	static ArrayList<Integer>q,w,primes;
	static ArrayList<Integer>adj[];
	static HashSet<Integer>primesH;
	static boolean prime[];
	//static ArrayList<Integer>a;
	static HashSet<Long>h,tmp;
	static boolean[]vis;
	static int[]a,b,c,d;
	static int[][] dp;
	static int dr[][];
	static int A,B,n,m,k,mt[][];
	static int oo=Integer.MIN_VALUE;
	static String s,tt;
	public static void main(String[]args) throws IOException {
		sc=new Scanner(System.in);
		out=new PrintWriter(System.out);
		//A();
    	//B();
		//primes=new ArrayList<Integer>();
		//primesH=new HashSet<Integer>();
	//	sieveOfEratosthenes(50);
		//C();
		D();
		//E();
		//minimum for subarrays of fixed length
		//F();
		out.close();
	}
	  private static void A() throws IOException {
		  int t=ni();
			while(t-->0) {
				int n=ni();
				a=nai(n);
				long ans=0;
				for(int i=0;i<n-1;i++) {
					int mx=Math.max(a[i], a[i+1]);
					int mn=Math.min(a[i], a[i+1]);
					if(mx<=2*mn)continue;
					int cur=(int)Math.ceil(mx/2.0);
					ans++;
					while(cur>2*mn) {
						ans++;
						cur=(int)Math.ceil(cur/2.0);
					}
				}
				out.println(ans);
			}
		
	   }
		static void B() throws IOException {
			int t=ni();
			while(t-->0) {
				int n=ni();
				a=nai(n);
				int c0=0,c1=0,c2=0;
				for(int i=0;i<n;i++) {
					if(a[i]%3==0)c0++;
					else if(a[i]%3==1)c1++;
					else c2++;
				}
				
						
			}
		}
		static void B2() throws IOException {
			 int t=ni();
			  while(t-->0) {
				  int n=ni(),k=ni();
					int[]pt=new int[2*n];
					boolean dec=true;
					for(int i=0,cnt=n;i<pt.length;i++) {
						pt[i]=cnt;
						cnt--;
						if(cnt==0)cnt=n;
					}
					//disp(pt);
					if(n%2==0) {
						out.println(k%n==0?n:k%n);
					}
					else {
					
							int[]pt2=new int[n*n+1];
							dec=false;
							for(int i=0,cnt=1;i<pt2.length;i++) {
								if(cnt==pt[i%n]) {
									cnt++;
								}
								pt2[i]=cnt;
								cnt++;
								if(cnt>=n) {
									cnt=1;
								}
								
								
							}
							
							out.println(pt2[(k-1)%(2*n)]);
					}
				  
				  
			  }
		}
	  static void C() throws IOException {
		  int t=ni();
		  while(t-->0) {
			  long n=sc.nextLong();
			
			  long lrg=1;
			  for(;lrg*lrg*lrg*1l<=n;lrg++) {
				 // out.println("ji");
			  }
	
			  
			  long[] pows=new long[((int)lrg)+1];
			  for(long i=1;i<pows.length;i++) {
				  pows[(int)i]=i*i*i*1l;
			  }
			//  disp(pows);
			  boolean f=false;
			  for(;lrg>0&&!f;lrg--) {
				  long trgt=n-lrg*lrg*lrg*1l;
				  if(trgt<=0)continue;
				  int lo=0,hi=pows.length-1;
				  while(lo<=hi) {
					  int mid=(lo+hi)/2;
					  if(pows[mid]==trgt) {
						  f=true;
						  break;
					  }else if(pows[mid]<trgt) {
						  lo=mid+1;
					  }else {
						  hi=mid-1;
					  }
			  }
			  }
			  out.println(f?"YES":"NO");
		  }
			
		  
		  
		}



	static void D() throws IOException {
		int t=ni();
		while(t-->0) {
			n=ni();
			a=nai(n);
			vis=new boolean[n];
			d=new int[n];
	
			dfs(get(0,n-1,Integer.MAX_VALUE));
			for(int x:d) {
				out.print(x+" ");
			}
			out.println();
		}
		
		
		
	}
	private static void dfs(int u) {
		vis[u]=true;
		int left=get(0,u-1,a[u]);
		int right=get(u+1,n-1,a[u]);
		if(left!=-1) {
			d[left]=d[u]+1;
			dfs(left);
			
		}
		if(right!=-1) {
			d[right]=d[u]+1;
			dfs(right);
			
		}
	}
	static int get(int x,int y,int cur) {
		int max=0,maxIdx=-1;
		for(int i=x;i<=y;i++) {
			if(a[i]>max&&!vis[i]&&a[i]<cur) {
				max=a[i];
				maxIdx=i;
			}
		}
		return maxIdx;
	}
	private static int sum(char[] ss) {
		int sum=0;
		for(int i=0;i<ss.length;i++) {
			sum+=(ss[i]-'0');
		}
		return sum;
	}
	static int gcd (int a, int b) {
	    return b==0?a:gcd (b, a % b);
	}
	static int lcm (int a, int b) {
	    return a / gcd(a, b) * b;
	}
	static void E() throws IOException {
		int t=ni();
		while(t-->0) {
			
			
		}
		
		
		
	}
	static final Random random=new Random();
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	static void F() throws IOException{
		int t=1;
		while(t-->0) {
			
		}
		
	}


	
	static void G() throws IOException{
		int t=1;
		while(t-->0) {

			
			
			
		}
		
	}
	private static void disp(long[] pows) {
		for(int i=0;i<pows.length;i++) {
			out.print(pows[i]+" ");
		}
		out.println();
	}

	static int ni() throws IOException {
		return sc.nextInt();
	}
	static double nd() throws IOException {
		return sc.nextDouble();
	}
	static long nl() throws IOException {
		return  sc.nextLong();
	}
	static String ns() throws IOException {
		return sc.next();
	}
	static int[] nai(int n) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		return a;
	}
	static long[] nal(int n) throws IOException {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		return a;
	}
	static int[][] nmi(int n,int m) throws IOException{
		int[][]a=new int[n][m];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=sc.nextInt();
			}
		}
		return a;
	}

	static long[][] nml(int n,int m) throws IOException{
		long[][]a=new long[n][m];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=sc.nextLong();
			}
		}
		return a;
	}
	static void o(String x) {
		out.print(x);
	}
	static void ol(String x) {
		out.println(x);
	}
	static void ol(int x) {
		out.println(x);
	}
	static void disp1(int []a) {
		for(int i=0;i<a.length;i++) {
			out.print(a[i]+" ");
		}
		out.println();
	}

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public boolean hasNext() {return st.hasMoreTokens();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
			
		public boolean ready() throws IOException {return br.ready(); }
		

	}
}
