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;
const int N = 8505;
int T, n, res, t, a[N << 1], tim[N], ans[N], pre[N], suf[N];
bool b[N], p[5];
inline int read() {
  char c = getchar();
  int ans = 0;
  while (c < 48 || c > 57) c = getchar();
  while (c >= 48 && c <= 57)
    ans = (ans << 3) + (ans << 1) + (c ^ 48), c = getchar();
  return ans;
}
inline void write(int x, char c) {
  int num = 0;
  char sc[15];
  while (x) sc[++num] = x % 10 + 48, x /= 10;
  while (num) putchar(sc[num--]);
  putchar(c);
}
inline int max(int x, int y) { return x > y ? x : y; }
inline bool cmp(int x, int y) { return tim[x] < tim[y]; }
inline void add_pre(int x) {
  for (register int i = x; i <= n; i += i & -i) pre[i] = max(pre[i], x);
}
inline void add_suf(int x) {
  for (register int i = x; i <= n; i += i & -i) suf[i] = max(suf[i], x);
}
inline int que_pre(int x) {
  int ans = 0;
  while (x) ans = max(ans, pre[x]), x -= x & -x;
  return ans;
}
inline int que_suf(int x) {
  int ans = 0;
  while (x) ans = max(ans, suf[x]), x -= x & -x;
  return ans;
}
inline void sol(int l, int r) {
  if (r - l + 1 <= 4) {
    sort(a + l + 1, a + r + 1, cmp);
    ans[a[l]] = ++t;
    if (l < r) ans[a[l + 1]] = ++t;
    if (l + 1 < r) ans[a[l + 2]] = ++t;
    if (l + 2 < r) {
      if (a[l + 1] < a[l]) swap(a[l], a[l + 1]);
      if (a[l + 2] < a[l]) swap(a[l], a[l + 2]);
      if (a[l + 2] < a[l + 1]) swap(a[l + 1], a[l + 2]);
      ans[a[l + 3]] = ans[a[(a[l + 3] < a[l] || a[l + 3] > a[l + 2])
                                ? l + 1
                                : (a[l + 3] < a[l + 1] ? l + 2 : l)]];
    }
    return;
  }
  for (register int i = l; i <= r; i += 3) {
    a[++res] = a[i];
    if (i < r && tim[a[i + 1]] < tim[a[i]]) a[res] = a[i + 1];
    if (i + 1 < r && tim[a[i + 2]] < tim[a[res]]) a[res] = a[i + 2];
  }
  sol(r + 1, res);
  for (register int i = l; i <= r; ++i)
    if (ans[a[i]]) b[a[i]] = 1;
  sort(a + l + 1, a + r + 1, cmp);
  for (register int i = 1; i <= n; ++i) pre[i] = suf[i] = 0;
  for (register int i = l; i <= r; ++i) {
    if (!ans[a[i]]) {
      int u = que_pre(a[i] - 1), v = n - que_suf(n - a[i]) + 1, cnt0 = 0,
          cnt1 = 0;
      p[1] = p[2] = p[3] = 0;
      if (!b[u]) {
        ++cnt0, p[ans[u] - t] = 1, u = que_pre(u - 1);
        if (!b[u]) ++cnt0, p[ans[u] - t] = 1;
      }
      if (!b[v]) {
        ++cnt1, p[ans[v] - t] = 1, v = n - que_suf(n - v) + 1;
        if (!b[v]) ++cnt1, p[ans[v] - t] = 1;
      }
      if (!p[1])
        ans[a[i]] = t + 1;
      else if (!p[2])
        ans[a[i]] = t + 2;
      else if (!p[3])
        ans[a[i]] = t + 3;
      else if (cnt0 > 1)
        ans[a[i]] = ans[u];
      else
        ans[a[i]] = ans[v];
    }
    add_pre(a[i]), add_suf(n - a[i] + 1);
  }
  t += 3;
}
int main() {
  T = read(), b[0] = 1;
  while (T--) {
    n = res = read(), t = 0, b[n + 1] = 1;
    for (register int i = 1; i <= n; ++i)
      tim[read()] = a[i] = i, ans[i] = b[i] = 0;
    sol(1, n);
    for (register int i = 1; i <= n; ++i) write(ans[i], i < n ? ' ' : '\n');
  }
  return 0;
}