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 
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
#define sei set<int>
#define sell set<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vld vector<ld>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(v) v.begin(), v.end()
#define all_(v) v.rbegin(), v.rend()
#define foa(i, v) for (auto i : v)
#define fo(i, a, b) for (int i = a; i < b; i++)
#define fo_(i, a, b) for (int i = a; i >= b; i--)
#define tt    \
    ll t;     \
    cin >> t; \
    while (t--)
#define M1(a) memset(a, 0, sizeof a)
#define M_(a) memset(a, -1, sizeof a)
#define deb(x) cerr << #x << " = " << x << endl
#define pb push_back
#define fi first
#define se second
#define N 1000005
#define M 1000000007
#define OK order_of_key
#define FO find_by_order
#define nmax 1000100
#define bolt                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
const ld PI = 3.141592653589793238462643383279;
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9 + 7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
/*/-----------------------------MODULAR ARITHMETIC----------------------------------/*/
 
inline ll add(ll x, ll y, ll mod) {
    x += y;
    if (x >= mod) return x - mod;
    return x % mod;
}
inline ll sub(ll x, ll y, ll mod) {
    x -= y;
    if (x < 0) return x + mod;
    return x;
}
inline ll mul(ll x, ll y, ll mod) {
    return (x * 1ll * y) % mod;
}
inline ll expo(ll x, ll y, ll mod) {
    ll ans = 1;
    while (y) {
        if (y & 1) ans = mul(ans, x, mod);
        x = mul(x, x, mod);
        y >>= 1;
    }
    return ans % mod;
}
inline ll inv(ll x, ll mod) {
    return expo(x, mod - 2, mod);
}
/*/-----------------------------INLINE FUNCTIONS----------------------------------/*/
 
inline ll gcd(ll a, ll b)          {if (b == 0) return a;    return gcd(b, a % b);}
inline ll lcm(ll a, ll b)          {return (a / gcd(a, b) * b);}
inline bool prime(ll n)            {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
inline ll ceil(ll num, ll den)      {return ((num + den - 1) / den);}

//Prime Numbers
vector<bool> p(N + 1, true);
void sieve(){
    ll i, j, k;
    p[0] = p[1] = false;
    for (i = 2; i * i <= N; i++)
        if (p[i])
            for (j = i * i; j <= N; j++)
                p[j] = false;
}

/*/-----------------------------Exponentiation----------------------------------/*/
ll power(ll a, ll b)
{
    ll r = 1;
    while (b)
    {
        if (b % 2 == 1)
            r = r * a;
        b /= 2;
        a *= a;
    }
    return r;
}
ll power(ll a, ll b, ll m)
{
    a = a % m;
    ll r = 1;
    while (b)
    {
        if (b % 2 == 1)
            r = (r * a) % m;
        b /= 2;
        a = (a * a) % m;
    }
    return r;
}

// 1 2 1 , 1 2 1 3 1 2 1, 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 ...
ll Power(ll a, ll b)
{
    if (b == 0)
        return 1;
    else if (b % 2 == 0)
        return power(a * a, b / 2);
    else
        return a * power(a, b - 1);
}

//Prime Factors
vector<ll> factors(ll n)
{
    vector<ll> r;
    ll i, j;
    for (i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            r.push_back(i);
            if (n / i != i)
                r.push_back(n / i);
        }
    }
    return r;
}

bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.second < b.second); }
vi ans(1000),v(10000);
void fun(int l, int r, int d){
    if(l>r)return;
    int te = l;
    fo(i,l,r+1)
        if(v[i]>v[te]) te = i;
    ans[te]=d;
    fun(l,te-1,d+1);
    fun(te+1,r,d+1);
    return;
}
int main()
{
    bolt;
    tt
    {
        ll n;
        cin>>n;
        fo(i,0,n)
            cin>>v[i];
        fun(0,n-1,0);
        fo(i,0,n)
            cout<<ans[i]<<' ';
        cout<<endl;    
    }
    return 0;
}