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 javax.sound.midi.Soundbank;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;

public class Main {
    static Reader br = new Reader();
    static int mod = 1000000007;

    public static long gcd(long a, long b) {
        while (b > 0) {
            long c = a;
            a = b;
            b = c % b;
        }
        return a;
    }

    public static int ni() throws IOException {
        return br.nextInt();
    }

    public static int max(int a, int b) {
        return Integer.max(a, b);
    }

    public static long max(long a, long b) {
        return Long.max(a, b);
    }

    public static double max(double a, double b) {
        return Double.max(a, b);
    }

    public static int min(int a, int b) {
        return Integer.min(a, b);
    }

    public static long min(long a, long b) {
        return Long.min(a, b);
    }

    public static double min(double a, double b) {
        return Double.min(a, b);
    }


    public static long nl() throws IOException {
        return br.nextLong();
    }

    public static double nd() throws IOException {
        return br.nextDouble();
    }

    public static int[] nia(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = ni();
        }
        return a;
    }

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

    static boolean isPowerOfTwo(long x) {
      /* First x in the below expression is
        for the case when x is 0 */
        return x != 0 && ((x & (x - 1)) == 0);

    }

    public static void main(String[] args) throws IOException {
        //a();
        //b();
        //ct();
        d();
        //e();
    }

    //Problem A
    static void a() throws IOException {
        int t = ni();
        while (t-- > 0) {
            int n = ni();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            int res=0;
            for (int i = 0; i < n - 1; i++) {

                int mx = max(a[i], a[i + 1]);
                int mn = min(a[i], a[i + 1]);
                if (mx > 2 * mn) {
                    int x = a[i];
                    if(a[i+1]>a[i]){
                        while(x<a[i+1]) {
                            x*=2;
                            res++;
                            //System.out.println(x+" "+a[i+1]);
                        }
                    }else{
                        while(x>a[i+1]){
                            x = (int) Math.ceil((double) x/2.0);
                            res++;
                            //System.out.println(x+" "+a[i+1]);
                        }
                    }
                    res--;
                }
                //System.out.println(res);
            }
            System.out.println(res);
        }
    }

    //Problem B
    static void b() throws IOException {
        int t = ni();
        while (t-- > 0) {
            int n = ni();
            int[] a = new int[n];
            int[] rem = new int[n];
            ArrayList<Integer> cl0 = new ArrayList<>();
            ArrayList<Integer> cl1 = new ArrayList<>();
            ArrayList<Integer> cl2 = new ArrayList<>();
            int c0=0,c1=0,c2=0;
            for (int i = 0; i < n; i++) {
                a[i] = ni();
                int r = a[i]%3;
                rem[i] = r;
                if(r==0) {
                    c0++;
                    cl0.add(a[i]);
                }
                else if(r==1) {
                    c1++;
                    cl1.add(a[i]);
                }
                else {
                    c2++;
                    cl2.add(a[i]);
                }
            }
            int total = n/3;
            Collections.sort(cl0);
            Collections.sort(cl1);
            Collections.sort(cl2);
            int flag0=0;
            int flag1=0;
            int flag2=0;
            if(c0==total)
                flag0=1;
            if(c1==total)
                flag1=1;
            if(c2==total)
                flag2=1;
            long ans=0;
            //System.out.println(c0+" "+c1+" "+c2);
            while(flag0==0 || flag1==0 || flag2==0){
                if(c0==total)
                    flag0=1;
                if(c1==total)
                    flag1=1;
                if(c2==total)
                    flag2=1;

                if((flag0==0 || flag1==0 || flag2==0)){
                    if(c0<total){
                        if(c1>c2){
                            c0++;
                            c1--;
                            ans++;

                        }else{
                            c0++;
                            c2--;
                        }
                        ans++;
                    }
                    if(c1<total){
                        if(c0>c2){
                            c1++;
                            c0--;

                        }else{
                            c1++;
                            c2--;
                            ans++;
                        }
                        ans++;
                    }
                    if(c2<total){
                        if(c0>c1){
                            c2++;
                            c0--;
                            ans++;

                        }else{
                            c2++;
                            c1--;
                        }
                        ans++;
                    }
                }


            }
            //System.out.println(c0+" "+c1+" "+c2);
            System.out.println(ans);
        }
    }

    static void ct() throws IOException {
        int t = ni();
        HashMap<Long,Integer> map= new HashMap<>();
        while (t-- > 0) {
            long x = nl();
            int flag=0;
            for (long i = 1; (long) i *i*i <= x; i++) {
                map.put(i*i*i,1);
                if(map.containsKey(x - i*i*i)){
                    System.out.println("Yes");
                    flag=1;
                    break;
                }
            }
            if(flag==0)
                System.out.println("No");
        }
    }


    //Problem C
    static void c() throws IOException {
        int t = ni();
        HashSet<Long> set = new HashSet<>();
        long[] list = new long[10001];
        for (long i = 1; i <= 10000; i++) {
            list[(int) i] = i*i*i;
        }
        System.out.println(list.length);
        for (int i = 1; i <= 10000; i++){
            for (int j = 1; j <= 10000; j++) {
                set.add(list[i]+list[j]);
            }
        }
        System.out.println(set.size());
        while (t-- > 0) {
            long x = nl();
            if(set.contains(x))
                System.out.println("Yes");
            else
                System.out.println("No");
        }
    }

    //Problem D
    static void d() throws IOException {
        int t = ni();
        while (t-- > 0) {
            int n = ni();
            int[] a = nia(n);
            int[] b = new int[n];
            bin(a,0,n-1,0,b);
            for (int i = 0; i < n; i++) {
                System.out.print(b[i]+" ");
            }
            System.out.println();
        }
    }
    static void bin(int arr[], int l, int r, int x,int[] b){
        int max=arr[l];
        int mi=l;
        for (int i = l; i <= r; i++) {
            if(max < arr[i]){
                max=arr[i];
                mi=i;

            }
        }
        b[mi]=x;

        //System.out.println();
        if(mi-1>=l)
            bin(arr,l,mi-1,x+1,b);
        if(mi+1<=r){
            bin(arr,mi+1,r,x+1,b);
        }
    }

    //Problem E
    static void e() throws IOException {
        int t = ni();
        while (t-- > 0) {
            //int n = ni();
        }
    }


    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }
}