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 static java.lang.Math.*;


import java.io.*;
import java.util.*;

public class Main {

    final static PrintWriter out = new PrintWriter(System.out);
    final static FastScanner sc = new FastScanner(System.in);

    public static void main(String[] args) throws IOException {
        Main ob = new Main();
        int t = sc.readInt();
        while (t-- > 0) {
            ob.solve();
        }
        out.close();
    }

    int n;
    int a[];
    int nas[];

    int range_max(int l, int r){
        int res = Integer.MIN_VALUE;
        int idx = l;
        for(int i = l; i <= r; ++i){
            if (a[i] > res) {
                res = a[i];
                idx = i;
            }
        }
        return idx;
    }

    void dfs(int L, int R, int d){
        if(L > R){
            return;
        }
        int idx = range_max(L, R);
        nas[idx] = d;
        if(L < R){
            dfs(L, idx - 1, d + 1);
            dfs(idx + 1, R, d + 1);
        }
    }

    void solve() throws IOException {
        // --- code per test case starts here ---
        n = sc.readInt();
        a = new int [n];
        nas = new int [n];
        Arrays.fill(nas, -1);
        for(int i = 0; i < n; ++i){
            a[i] = sc.readInt() - 1;
        }
        dfs(0, n - 1, 0);
        for(int i = 0; i < n; ++i){
            out.print(nas[i] + " ");
        }
        out.println();
    }

    public static class Utility {
        static final double EPS = 10e-6;

        public static int lower_bound(int[] a, int x) {
            int left = 0, right = a.length, mid = -1;

            while (left < right) {
                mid = (left + right) / 2;
                if (a[mid] >= x) {
                    right = mid;
                } else {
                    left = mid + 1;
                }

            }
            return left;
        }

        public static int upper_bound(int[] arr, int x) {
            int left = 0, right = arr.length, mid = -1;
            while (left < right) {
                mid = (left + right) / 2;
                if (arr[mid] > x) {
                    right = mid;
                } else {
                    left = mid + 1;
                }
            }
            return left;
        }

        public static int gcd(int a, int b) {
            return b == 0 ? a : gcd(b, a % b);
        }

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

        public static long fast_pow_mod(long b, long x, int mod) {
            if (x == 0)
                return 1;
            if (x == 1)
                return b;
            if (x % 2 == 0)
                return fast_pow_mod(b * b % mod, x / 2, mod) % mod;

            return b * fast_pow_mod(b * b % mod, x / 2, mod) % mod;
        }

        public static int fast_pow(int b, int x) {
            if (x == 0)
                return 1;
            if (x == 1)
                return b;
            if (x % 2 == 0)
                return fast_pow(b * b, x / 2);

            return b * fast_pow(b * b, x / 2);
        }

        public static long choose(long n, long k) {
            k = min(k, n - k);
            long val = 1;

            for (int i = 0; i < k; ++i)
                val = val * (n - i) / (i + 1);

            return val;
        }

        public static long permute(int n, int k) {
            if (n < k)
                return 0;
            long val = 1;

            for (int i = 0; i < k; ++i)
                val = (val * (n - i));

            return val;
        }
    }

    public static class FastScanner {
        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar, numChars;

        public FastScanner(InputStream stream) {
            this.stream = stream;
        }

        public FastScanner(String file) throws IOException {
            this.stream = new FileInputStream(file);
        }

        public int readChar() throws IOException {
            if (curChar >= numChars) {
                curChar = 0;
                numChars = stream.read(buf);
            }

            if (numChars == -1)
                return numChars;

            return buf[curChar++];
        }

        public int readInt() throws IOException {
            int c = readChar(), sgn = 1;

            while (isSpace(c))
                c = readChar();

            if (c == '-') {
                sgn = -1;
                c = readChar();
            }

            int res = 0;

            do {
                res = (res << 1) + (res << 3);
                res += c - '0';
                c = readChar();
            } while (!isSpace(c));

            return res * sgn;
        }

        public String readString() throws IOException {
            int c = readChar();

            while (isSpace(c))
                c = readChar();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = readChar();
            } while (!isSpace(c));

            return res.toString();
        }

        public double readDouble() throws IOException {
            int c = readChar(), sgn = 1;

            while (isSpace(c))
                c = readChar();

            if (c == '-') {
                sgn = -1;
                c = readChar();
            }

            double res = 0;

            while (!isSpace(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Utility.fast_pow(10, readInt());

                res *= 10;
                res += c - '0';
                c = readChar();
            }

            if (c == '.') {
                c = readChar();
                double m = 1;

                while (!isSpace(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Utility.fast_pow(10, readInt());

                    m /= 10;
                    res += (c - '0') * m;
                    c = readChar();
                }
            }

            return res * sgn;
        }

        public long readLong() throws IOException {
            int c = readChar(), sgn = 1;

            while (isSpace(c))
                c = readChar();

            if (c == '-') {
                sgn = -1;
                c = readChar();
            }

            long res = 0;

            do {
                res = (res << 1) + (res << 3);
                res += c - '0';
                c = readChar();
            } while (!isSpace(c));

            return res * sgn;
        }
        public int[] readIntArray(int n) throws IOException {
            int a[] = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = readInt();
            }
            return a;
        }

        public long[] readLongArray(int n) throws IOException {
            long a[] = new long[n];
            for (int i = 0; i < n; ++i) {
                a[i] = readLong();
            }
            return a;
        }

        public String[] readStringArray(int n) throws IOException {
            String a[] = new String[n];
            for (int i = 0; i < n; ++i) {
                a[i] = readString();
            }
            return a;
        }
        public boolean isSpace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }

    public static class Debug {
        public static final boolean LOCAL = System.getProperty("ONLINE_JUDGE") == null;

        private static <T> String ts(T t) {
            if (t == null) {
                return "null";
            }
            try {
                return ts((Iterable) t);
            } catch (ClassCastException e) {
                if (t instanceof int[]) {
                    String s = Arrays.toString((int[]) t);
                    return "{" + s.substring(1, s.length() - 1) + "}";
                } else if (t instanceof long[]) {
                    String s = Arrays.toString((long[]) t);
                    return "{" + s.substring(1, s.length() - 1) + "}";
                } else if (t instanceof char[]) {
                    String s = Arrays.toString((char[]) t);
                    return "{" + s.substring(1, s.length() - 1) + "}";
                } else if (t instanceof double[]) {
                    String s = Arrays.toString((double[]) t);
                    return "{" + s.substring(1, s.length() - 1) + "}";
                } else if (t instanceof boolean[]) {
                    String s = Arrays.toString((boolean[]) t);
                    return "{" + s.substring(1, s.length() - 1) + "}";
                }
                try {
                    return ts((Object[]) t);
                } catch (ClassCastException e1) {
                    return t.toString();
                }
            }
        }

        private static <T> String ts(T[] arr) {
            StringBuilder ret = new StringBuilder();
            ret.append("{");
            boolean first = true;
            for (T t : arr) {
                if (!first) {
                    ret.append(", ");
                }
                first = false;
                ret.append(ts(t));
            }
            ret.append("}");
            return ret.toString();
        }

        private static <T> String ts(Iterable<T> iter) {
            StringBuilder ret = new StringBuilder();
            ret.append("{");
            boolean first = true;
            for (T t : iter) {
                if (!first) {
                    ret.append(", ");
                }
                first = false;
                ret.append(ts(t));
            }
            ret.append("}");
            return ret.toString();
        }

        public static void dbg(Object... o) {
            if (LOCAL) {
                System.err.print("Line #" + Thread.currentThread().getStackTrace()[2].getLineNumber() + ": [");
                for (int i = 0; i < o.length; i++) {
                    if (i != 0) {
                        System.err.print(", ");
                    }
                    System.err.print(ts(o[i]));
                }
                System.err.println("]");
            }
        }
    }
}