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;
using ll = long long;
template <class T>
void read(T &x) {
  char ch;
  x = 0;
  int f = 1;
  while (isspace(ch = getchar()))
    ;
  if (ch == '-') ch = getchar(), f = -1;
  do x = x * 10 + (ch - '0');
  while (isdigit(ch = getchar()));
  x *= f;
}
template <class T, class... A>
void read(T &x, A &...args) {
  read(x);
  read(args...);
}
template <class CRIter, class RIter>
void cons_4(CRIter l, CRIter r, RIter res, int start) {
  static int a[4];
  iota(a, a + (r - l), 0);
  sort(a, a + (r - l), [&](int a, int b) { return l[a] < l[b]; });
  fill_n(res, r - l, 0);
  for (int i = 0, li = min<int>(r - l, 3); i < li; ++i) res[a[i]] = i + start;
  if (r - l == 4) {
    bool vis[3] = {false, false, false};
    int p = a[3];
    if (p != 0 && res[p - 1]) vis[res[p - 1] - start] = true;
    if (p + 1 != r - l && res[p + 1]) vis[res[p + 1] - start] = true;
    for (int j = 0; j < 3; ++j)
      if (!vis[j]) {
        res[p] = j + start;
        break;
      }
  }
}
vector<int> cons(const vector<int> &a, int start = 22) {
  if (a.size() <= 4) {
    vector<int> res(a.size());
    cons_4(a.begin(), a.end(), res.begin(), start);
    return res;
  }
  int n = a.size();
  vector<int> b((n + 2) / 3);
  vector<bool> ismn(n);
  for (size_t i = 0; i != b.size(); ++i) {
    int pos =
        min_element(a.begin() + 3 * i, a.begin() + min(a.size(), 3 * i + 3)) -
        a.begin();
    b[i] = a[pos];
    ismn[pos] = true;
  }
  vector<int> c = cons(b, start - 3);
  vector<int> res(n), nmin(n);
  iota(nmin.begin(), nmin.end(), 0);
  auto cpos = c.begin();
  for (int i = 0; i < n; ++i)
    if (ismn[i]) res[i] = *(cpos++);
  sort(nmin.begin(), nmin.end(), [&](int x, int y) { return a[x] < a[y]; });
  set<int> s;
  for (int p : nmin) {
    auto it = s.insert(p).first;
    if (ismn[p]) continue;
    bool vis[3] = {false, false, false};
    int cnt[3] = {0, 0, 0};
    if (it != s.begin() && !ismn[*prev(it)]) vis[res[*prev(it)] - start] = true;
    if (next(it) != s.end() && !ismn[*next(it)])
      vis[res[*next(it)] - start] = true;
    auto i = it;
    while (true) {
      if (i == s.begin()) break;
      --i;
      if (ismn[*i]) break;
      ++cnt[res[*i] - start];
    }
    i = it;
    while (true) {
      ++i;
      if (i == s.end() || ismn[*i]) break;
      ++cnt[res[*i] - start];
    }
    bool flag = find(cnt, cnt + 3, 2) != cnt + 3;
    for (int i = 0; i < 3; ++i)
      if (!vis[i] && !(flag && cnt[i])) {
        res[p] = i + start;
        break;
      }
  }
  return res;
}
int main() {
  int T;
  read(T);
  while (T--) {
    int n;
    read(n);
    vector<int> a(n);
    for (int i = 0, x; i < n; ++i) {
      read(x);
      a[x - 1] = i;
    }
    for (int x : cons(a)) printf("%d ", x);
    putchar('\n');
  }
  return 0;
}