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 JAVA):

Solution:
import java.io.*;
import java.math.*;
import java.util.*;
public class Q4 {
	static int INF = (int)(1e9);
	static long mod = (long)(1e9)+7;
	static long mod2 = 998244353;
	static long[] segtree;
	static char[] curans;
	static long ans;	
	static String S;
	static ArrayList<Integer>[] graph;
	static boolean[] vis;
	static int[] a;
	static int N;
	static long K;
	static long[] fact;
	static ArrayList<Long> pos;
	static ArrayList<Long> neg;
	static long[] max;
	static int[] dp;
	public static void main(String[] args) {  //Cash out
		/**/
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int T = I.nextInt();
		StringBuilder ret = new StringBuilder();
		while (T-- > 0) {
			int N = I.nextInt();
			a = new int[N];
			dp = new int[N + 1];
			for (int i = 0; i < N; i++) {
				a[i] = I.nextInt();
			}
			
			recurse(0, 0, N - 1);
			
			for (int i = 0; i < N; i++) {
				ret.append(dp[a[i]] + " ");
			}
			ret.append("\n");
		}
		O.pln(ret);
	}
	public static void recurse(int tree_depth, int L, int R) {
		if (L <= R) {
			int max_index = 0;
			int max = 0;
			for (int i = L; i <= R; i++) {
				if (a[i] > max) {
					max = a[i];
					max_index = i;
				}
			}
			dp[max] = tree_depth;
			recurse(tree_depth + 1, L, max_index - 1);
			recurse(tree_depth + 1, max_index + 1, R);
		}
	}
	public static double[][] matrix_exp(double[][] a, long exp, long mod) {
		int R = a.length;
		int C = a[0].length;
		double[][] ans = new double[R][C];
		
		boolean mult_yet = false;
		
		while (exp > 0) {
			if (exp % 2 == 1) {
				if (!mult_yet) {
					mult_yet = true;
					for (int i = 0; i < R; i++) {
						for (int j = 0; j < C; j++) {
							ans[i][j] = a[i][j]; 
						}
					}
				}else {
					double[][] new_ans = mult(ans, a, mod);
					for (int i = 0; i < R; i++) {
						for (int j = 0; j < C; j++) {
							ans[i][j] = new_ans[i][j]; 
						}
					}
				}
			}
			
			double[][] new_a = mult(a, a, mod); // a = a^2 (binary exponentiation on matrices)
			for (int i = 0; i < R; i++) {
				for (int j = 0; j < C; j++) {
					a[i][j] = new_a[i][j]; 
				}
			}
			exp /= 2;
		}
		
		return ans;
	}
	public static double[][] mult(double[][] a, double[][] b, long mod) {
		int r1 = a.length;
		int c1 = a[0].length;
		int r2 = b.length;
		int c2 = b[0].length;
		//Requires: c1 = r2
		
		double[][] ans = new double[r1][c2];
		for (int r = 0; r < r1; r++) {
			for (int c = 0; c < c2; c++) {
				//Dot product of (a[r])^T and b[c] (as vectors in R^n (n = c1 = r2))
				double[] col_vector = new double[r2];
				double[] row_vector = new double[c1];
				
				for (int i = 0; i < r2; i++) {
					col_vector[i] = b[i][c];
				}
				for (int i = 0; i < c1; i++) {
					row_vector[i] = a[r][i]; 
				}
				
				ans[r][c] = dot_product(row_vector, col_vector, mod);
			}
		}
		return ans;
	}
	
	public static double dot_product(double[] a, double[] b, long mod) {
		double ans = 0;
		int N = a.length; //Requires: a and b are both vectors in R^n
		for (int i = 0; i < N; i++) {
			ans += a[i] * b[i];
		}
		return ans;
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long abs(int x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}