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.util.Vector;
import java.util.*;
import java.lang.Math;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.management.Query;
import java.io.*;
import java.math.BigInteger;
import java.io.FileWriter;

public class Main {
    static int mod = 1000000007;

    static class Edge {
        int to;
        long time, k;

        public Edge(int to, long time, long k) {
            this.to = to;
            this.time = time;
            this.k = k;
        }
    }

    static class Pair implements Comparator<Pair> {
        long x;
        long y;

        // Constructor
        public Pair(long x, long y) {
            this.x = x;
            this.y = y;
        }

        public Pair() {
        }

        @Override
        public int compare(Main.Pair o1, Main.Pair o2) {
            if (o1.y < o2.y)
                return -1;
            if (o1.y > o2.y)
                return 1;
            return 0;
        }
    }

    // class to define user defined conparator
    static class Compare implements Comparator<Pair> {

        public int compare(Pair p1, Pair p2) {
            if (p1.x == p2.x) {
                if (p1.y > p2.y) {
                    return 1;
                } else if (p1.y == p2.y) {
                    return 0;
                } else {
                    return -1;
                }
            }
            if (p1.x > p2.x)
                return 1;
            else
                return -1;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] intArr(int n) {
            int res[] = new int[n];
            for (int i = 0; i < n; i++)
                res[i] = nextInt();
            return res;
        }

        long[] longArr(int n) {
            long res[] = new long[n];
            for (int i = 0; i < n; i++)
                res[i] = nextLong();
            return res;
        }
    }

    static FastReader f = new FastReader();

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (long i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

    static int LowerBound(int a[], int x) { // smallest index having value >= x
        int l = -1, r = a.length;
        while (l + 1 < r) {
            int m = (l + r) >>> 1;
            if (a[m] >= x)
                r = m;
            else
                l = m;
        }
        return r;
    }

    static int UpperBound(int a[], int x) {// biggest index having value <= x
        int l = -1, r = a.length;
        while (l + 1 < r) {
            int m = (l + r) >>> 1;
            if (a[m] <= x)
                l = m;
            else
                r = m;
        }
        return l + 1;
    }

    static long gcd(long a, long b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static long lcm(long a, long b) {
        return (a * b) / gcd(a, b);
    }

    static long power(long x, long y, long p) {
        long res = 1;
        x = x % p;
        while (y > 0) {
            if (y % 2 == 1)
                res = (res * x) % p;
            y = y >> 1; // y = y/2
            x = (x * x) % p;
        }
        return res;
    }

    static long power(long x, long y) {
        long res = 1;
        while (y > 0) {
            if (y % 2 == 1)
                res = (res * x);
            y >>= 1;
            x = (x * x);
        }
        return res;
    }

    static int power(int x, int y) {
        int res = 1;
        while (y > 0) {
            if (y % 2 == 1)
                res = (res * x);
            y >>= 1;
            x = (x * x);
        }
        return res;
    }

    static int ceil(int x, int y) {
        return (x % y == 0 ? x / y : (x / y + 1));
    }

    static long ceil(long x, long y) {
        return (x % y == 0 ? x / y : (x / y + 1));
    }

    /*
     * ===========Modular Operations==================
     */
    static long modInverse(long n, long p) {
        return power(n, p - 2, p);
    }

    static long modAdd(long a, long b) {
        return (a % mod + b % mod) % mod;

    }

    static long modMul(long a, long b) {
        return ((a % mod) * (b % mod)) % mod;
    }

    static long nCrModPFermat(int n, int r) {
        long p = 1000000007;
        if (r == 0)
            return 1;
        long[] fac = new long[n + 1];
        fac[0] = 1;
        for (int i = 1; i <= n; i++)
            fac[i] = fac[i - 1] * i % p;
        return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
    }

    /*
     * ===============================================
     */
    List<Integer> removeDup(ArrayList<Integer> list) {
        List<Integer> newList = list.stream().distinct().collect(Collectors.toList());
        return newList;
    }

    static void ruffleSort(long[] a) {
        int n = a.length;
        Random r = new Random();
        for (int i = 0; i < a.length; i++) {
            int oi = r.nextInt(n);
            long temp = a[i];
            a[i] = a[oi];
            a[oi] = temp;
        }
        Arrays.sort(a);
    }

    static void ruffleSort(int[] a) {
        int n = a.length;
        Random r = new Random();
        for (int i = 0; i < a.length; i++) {
            int oi = r.nextInt(n);
            int temp = a[i];
            a[i] = a[oi];
            a[oi] = temp;
        }
        Arrays.sort(a);
    }

    /*
     * ===========Dynamic prog Recur Section===========
     */

    static int DP[][];
    static ArrayList<ArrayList<Integer>> g;
    static int count=0;
    static void makeG(int head,int a[],boolean vis[],int leftLim,int rightLim) {
        if(head==-1){
            return;
        }
        vis[head]=true;
        int maxL=0,posL=-1,maxR=0,posR=-1;
        for(int i=leftLim;i<rightLim;i++){
            if(vis[i])continue;
            if(maxL<a[i]){
                maxL=a[i];
                posL=i;
            }
        }
        for(int i=leftLim;i<rightLim;i++){
            if(vis[i])continue;
            if(maxR<a[i]){
                maxR=a[i];
                posR=i;
            }
        }
        if(posL!=-1){
            g.get(head).add(posL);
            g.get(posL).add(head);
            makeG(posL,a,vis,0,head);
        }
        if(posR!=-1){
            g.get(head).add(posR);
            g.get(posR).add(head);
            makeG(posR, a,vis,head,a.length);
        }
        
    }

    /*
     * ====================================Main=================================
     */
    public static void main(String args[]) throws Exception {
        BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
        Random rand = new Random();
        int t = 1;
        t = f.nextInt();
        while (t-- != 0) {
            int n = f.nextInt();
            int a[]=new int[n];
            g=new ArrayList<>();
            for(int i=0;i<=n;i++){
                g.add(new ArrayList<>());
            }
            int maxL=0,posL=-1,maxR=0,posR=-1;
            for(int i=0;i<n;i++){
                a[i]=f.nextInt();
                if(maxL<a[i]){
                    maxL=a[i];posL=i;
                }
                if(maxR<a[i]){
                    maxR=a[i];posR=i;
                }
            }      
            int level[]=new int[n+1];
            boolean vis[]=new boolean[n+1];
            makeG(posL,a,vis,0,n);
            Queue<Integer> q=new LinkedList<>();
            q.add(posL);
            level[posL]=0;
            Arrays.fill(vis,false);
            while(!q.isEmpty()){
                int head=q.poll();
                vis[head]=true;
                for(int i:g.get(head)){
                    if(!vis[i]){
                        vis[i]=true;
                        level[i]=level[head]+1;
                        q.add(i);
                    }
                }
            }
            for(int i=0;i<n;i++){
                w.write(level[i]+" ");
            }
            w.write("\n");
        }
        w.flush();
    }
}