Problem: Very soon, the new cell phone services provider "BerLine" will begin its work in Berland!

The start of customer service is planned along the main street of the capital. There are n base stations that are already installed. They are located one after another along the main street in the order from the 1-st to the n-th from left to right. 

Currently, all these base stations are turned off. They will be turned on one by one, one base station per day, according to some permutation p = [p_1, p_2, ..., p_n] ( 1 ≤ p_i ≤ n), where p_i is the index of a base station that will be turned on on the i-th day. Thus, it will take n days to turn on all base stations.

Each base station is characterized by its operating frequency f_i — an integer between 1 and 24, inclusive.

There is an important requirement for operating frequencies of base stations. Consider an arbitrary moment in time. For any phone owner, if we consider all base stations turned on in the access area of their phone, then in this set of base stations there should be at least one whose operating frequency is unique among the frequencies of these stations. Since the power of the phone and the position are not known in advance, this means that for any nonempty subsegment of turned on base stations, at least one of them has to have the operating frequency that is unique among the stations of this subsegment.

For example, let's take a look at a case of n = 7, all n stations are turned on, and their frequencies are equal to f = [1, 2, 1, 3, 1, 2, 1]. Consider any subsegment of the base stations — there is a base station with a unique frequency within this subsegment. However, if f = [1, 2, 1, 2, 3, 2, 1], then there is no unique frequency on the segment [1, 2, 1, 2] from the index 1 to the index 4, inclusive.

Your task is to assign a frequency from 1 to 24 to each of n base stations in such a way that the frequency requirement is met at every moment. Remember that the base stations are turned on in the order of the given permutation p.

Input

The first line of the input contains an integer t (1 ≤ t ≤ 50) — the number of test cases in the input. Then t test case descriptions follow.

The first line of a test case contains an integer n ( 1 ≤ n ≤ 8 500) — the number of "BerLine" base stations.

The following line contains n distinct integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n) — the order in which the base stations are turned on, i. e. on the i-th day the base station with the index p_i is turned on.

It is guaranteed that a correct answer exists for all test cases in the input.

Output

Print exactly t lines, where the j-th line contains the answer for the j-th test case in the input. Print the required frequencies f_1, f_2, ..., f_n (1 ≤ f_i ≤ 24). If there are several possible answers, print any of them.

Example

Input


5
3
1 3 2
3
1 2 3
1
1
10
6 10 4 2 7 9 5 8 3 1
10
2 4 6 9 1 8 10 5 3 7


Output


1 3 2 
10 20 10
1 
2 3 4 5 3 1 3 5 4 2 
1 2 3 4 5 6 7 8 9 10

Note

In the first test case n = 3 and p = [1, 3, 2]. The base stations can be assigned frequencies [1, 3, 2].

  * Day 1: only the base station 1 is turned on, its frequency is 1. 
  * Day 2: the base stations 1 and 3 are turned on, their frequencies are [1, 2]. 
  * Day 3: all base stations are turned on, their frequencies are [1, 3, 2] (in the direction along the street). 



On each day, each nonempty subsegment of turned on base stations has a base station with a unique frequency among this subsegment. It can be shown that three distinct frequencies are necessary in this test case.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vc<vc<T>>;
template <class T>
void mkuni(vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
long long rand_int(long long l, long long r) {
  static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<long long>(l, r)(gen);
}
template <class T>
void print(T x, int suc = 1) {
  cout << x;
  if (suc == 1)
    cout << '\n';
  else
    cout << ' ';
}
template <class T>
void print(const vector<T> &v, int suc = 1) {
  for (int i = 0; i < v.size(); i++)
    print(v[i], i == (int)(v.size()) - 1 ? suc : 2);
}
vector<int> p;
vector<int> t;
vector<int> ans;
void fillans(vector<int> &a, int c) {
  assert(a.size() <= 4);
  vector<int> id(a.size());
  iota(id.begin(), id.end(), 0);
  sort(id.begin(), id.end(), [&](int x, int y) { return t[a[x]] < t[a[y]]; });
  for (auto u : id) {
    ans[a[u]] = c;
    c++;
  }
  c--;
  if (a.size() == 4) {
    for (int i = c - 3; i < c; i++) {
      bool suc = 1;
      if (id[3] != 0 && ans[a[id[3] - 1]] == i) suc = 0;
      if (id[3] != 3 && ans[a[id[3] + 1]] == i) suc = 0;
      if (suc) ans[a[id[3]]] = i;
    }
    assert(ans[a[id[3]]] != c);
  }
}
const int maxn = 1e4 + 7;
void solve(vector<int> a, int c = 1) {
  if (a.size() <= 4) {
    fillans(a, c);
    return;
  }
  vector<int> vis(maxn);
  vector<int> nxt;
  set<int> pos;
  for (int i = 0; i < a.size(); i += 3) {
    vector<int> tmp;
    vector<int> idd;
    for (int j = i; j < min((int)a.size(), i + 3); j++) {
      tmp.push_back(a[j]);
      idd.push_back(j);
    }
    vector<int> id(tmp.size());
    iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(),
         [&](int x, int y) { return t[tmp[x]] < t[tmp[y]]; });
    nxt.push_back(tmp[id[0]]);
    vis[tmp[id[0]]] = 1;
  }
  sort(a.begin(), a.end(), [&](int x, int y) { return t[x] < t[y]; });
  ;
  for (auto u : a) {
    if (vis[u]) {
      pos.insert(u);
      continue;
    }
    int l = -1, r = -1;
    auto it = pos.lower_bound(u);
    map<int, int> cnt;
    if (it != pos.end()) {
      if (!vis[*it]) {
        ;
        r = ans[*it];
        auto itr = it;
        while (itr != pos.end() && !vis[*itr]) {
          cnt[ans[*itr]]++;
          itr++;
        }
      }
    }
    if (it != pos.begin()) {
      it--;
      if (!vis[*it]) {
        l = ans[*it];
        do {
          if (vis[*it]) break;
          cnt[ans[*it]]++;
          if (it != pos.begin()) it--;
        } while (it != pos.begin());
      }
    };
    if (cnt[c] == 0)
      ans[u] = c;
    else if (cnt[c + 1] == 0)
      ans[u] = c + 1;
    else if (cnt[c + 2] == 0)
      ans[u] = c + 2;
    else {
      for (int j = c; j < c + 3; j++) {
        if (j != l && j != r) {
          ans[u] = j;
          break;
        }
      }
    }
    assert(ans[u]);
    pos.insert(u);
  };
  solve(nxt, c + 3);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    p = vector<int>(n);
    t = vector<int>(n);
    ans = vector<int>(n);
    for (int i = 0; i < n; i++) {
      cin >> p[i];
      p[i]--;
      t[p[i]] = i;
    }
    vector<int> all(n);
    iota(all.begin(), all.end(), 0);
    solve(all);
    print(ans);
  }
}