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.io.*;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;


/*
 * @author: Ramanqul
 * */
public class Main {
    private static boolean USE_TEST_CASES = true;
    private static final double EPS = .000000001;

    private static int findLower(long arr[], long x) {
        int l = -1, r = arr.length;

        while (r > l+1) {
            int mid = (l+r)/2;

            if (arr[mid] >= x) {
                r = mid;
            } else {
                l = mid;
            }
        }

        return r;
    }

    private static int binarySearch(Integer arr[][], int arrIdx, int key) {
        int l = 0, r = arr.length-1;

        while (l<=r) {
            int m = (l+r)/2;
            if (arr[m][arrIdx] < key) {
                l = m + 1;
            } else if (arr[m][arrIdx] > key) {
                r = m - 1;
            } else {
                return m;
            }
        }

        return -1;
    }

    private static int findUpper(int arr[], int x) {
        int l = -1, r = arr.length;

        while (r > l+1) {
            int mid = (l+r)/2;

            if (arr[mid] < x) {
                l = mid;
            } else {
                r = mid;
            }
        }

        return r;
    }

    private static int findUpper(int arr[][], int x[], Comparator<int[]> cmp) {
        int l = -1, r = arr.length;

        while (r > l+1) {
            int mid = (l+r)/2;

            if (arr[mid][2] == x[2]) {
                if (mid+1 < arr.length) {
                    mid++;
                } else {
                    mid--;
                }
            }

            if (cmp.compare(arr[mid], x) < 0) {
                l = mid;
            } else {
                r = mid;
            }
        }

        return r;
    }

    private static<T extends Number> long[] prefixSum(Iterable<T> iter, int size) {
        long sum[] = new long[size];
        int cnt = 0;
        Iterator<T> it = iter.iterator();
        while (it.hasNext()) {
            Number n = it.next();

            if (cnt == 0) {
                sum[cnt] = n.longValue();
            } else {
                sum[cnt] = sum[cnt-1] + n.longValue();
            }

            cnt++;
        }

        return sum;
    }

    private static int findMaxIndex(int a[], int from, int to) {
        int maxVal=a[from], maxIndex = from;

        for (int i=from;i<=to;i++) {
            if (maxVal < a[i]) {
                maxVal = a[i];
                maxIndex = i;
            }
        }

        return maxIndex;
    }
    private static void calcDepth(TreeNode root, int depth, Map<Integer, Integer> depthMap) {
        if (root == null) {
            return;
        }

        depthMap.put(root.val, depth);

        calcDepth(root.left, depth+1, depthMap);
        calcDepth(root.right, depth+1, depthMap);
    }

    private static TreeNode buildTree(TreeNode root, int a[], int from, int to) {
        int maxIndex = findMaxIndex(a, from ,to);

        if (root == null) {
            root = new TreeNode(a[maxIndex]);
        }

        if (maxIndex-1 >= from) {
            root.left = buildTree(root.left, a, from, maxIndex - 1);
        }

        if (maxIndex+1 <= to) {
            root.right = buildTree(root.right, a, maxIndex + 1, to);
        }

        return root;
    }

    private static void solve(final int testCase, MyScanner in, PrintWriter out) {
        int n = in.nextInt();
        int a[] = new int[n];
        H.readArray(in, a, n);

        TreeNode root = buildTree(null, a, 0, n-1);
        Map<Integer, Integer> depthMap = new HashMap<>();
        calcDepth(root, 0, depthMap);

        for (int i=0;i<n;i++) {
            out.print(depthMap.get(a[i]) + " ");
        }
        out.println();
    }

    private static void generateInput(String fileName) throws IOException {
        PrintWriter writer = new PrintWriter(new BufferedOutputStream(new FileOutputStream(fileName)));

        writer.println(1);
        final int n = 200_000;
        Random rnd = new Random();
        writer.println(n);

        for (int i=0;i<n;i++) {
            writer.print(rnd.nextInt(1+100));
            writer.print(" ");
        }

        writer.close();
    }

    public static void main(String[] args) throws IOException {
//        String fileName = "sample.in";

//        generateInput(fileName);

        MyScanner sc = new MyScanner();//new BufferedInputStream(new FileInputStream(fileName)));

        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int t = 1;

        if (USE_TEST_CASES) {
            t = sc.nextInt();
        }

        for (int i=0;i<t;i++) {
            solve(i, sc, out);
        }

        out.close();
    }

    private static class Pair<A,B> {
        public A first;
        public B second;
        public Pair(A first, B second) {
            this.first = first;
            this.second = second;
        }
    }

    private static class Triple<A,B,C> {
        public A first;
        public B second;
        public C third;

        public Triple(A first, B second, C third) {
            this.first = first;
            this.second = second;
            this.third = third;
        }
    }

    private static class TreeNode {
        public int val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode() {}
        public TreeNode(int val) {
            this.val = val;
        }
    }

    private static class H {
        public static void readArray(MyScanner in, int a[], int n) {
            for (int i=0;i<n;i++) {
                a[i] = in.nextInt();
            }
        }

        public static boolean isUnique(int ... nums) {
            Set<Integer> s = new HashSet<>();
            for (int i:nums) {
                if (s.contains(i)) {
                    return false;
                }
                s.add(i);
            }

            return true;
        }


        public static Pair<Integer, Integer>[] readIntPairs(MyScanner in, int n) {
            Pair[] pairs = new Pair[n];
            for (int i=0;i<n;i++) {
                int x = in.nextInt();
                int y = in.nextInt();
                pairs[i] = new Pair<Integer, Integer>(x, y);
            }

            return pairs;
        }

        public static List<Integer> dfs(int start, List<Integer>[] adj) {
            boolean v[] = new boolean[adj.length+1];

            List<Integer> res = new ArrayList<>();

            Stack<Integer> st = new Stack<>();

            st.push(start);

            while (!st.isEmpty()) {
                int x = st.pop();
                if (!v[x]) {
                    res.add(x);
                    boolean allVisited = true;
                    for (int e: adj[x]) {
                        if (!v[e]) {
                            st.push(e);
                            allVisited = false;
                        }
                    }

                    if (allVisited) {
                        break;
                    }

                    v[x] = true;
                } else {
                    break;
                }
            }

            return res;
        }

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

            return gcd(b%a, a);
        }

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

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public MyScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        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;
        }

    }
}