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;
vector<int> solve(vector<int> ps) {
  int lo = *min_element(ps.begin(), ps.end());
  for (auto& p : ps) {
    p -= lo;
  }
  int n = (int)ps.size();
  assert(*max_element(ps.begin(), ps.end()) == n - 1);
  vector<int> assigned(n, -1);
  if (n > 4) {
    int m = (n + 2) / 3;
    vector<int> first_from_segment(m, -1);
    vector<int> ps_m;
    for (int p : ps) {
      if (first_from_segment[p / 3] == -1) {
        first_from_segment[p / 3] = p;
        ps_m.push_back(p / 3);
      }
    }
    assert(ps_m.size() == m);
    auto rec_m = solve(ps_m);
    for (int i = 0; i < m; ++i) {
      assigned[first_from_segment[i]] = rec_m[i] + 3;
    }
  }
  set<int> turned_on;
  for (int p : ps) {
    turned_on.insert(p);
    if (assigned[p] != -1) {
      continue;
    }
    vector<int> left_neighbors, right_neighbors;
    {
      auto it = turned_on.find(p);
      while (it != turned_on.begin()) {
        --it;
        if (assigned[*it] > 3) {
          break;
        }
        left_neighbors.push_back(assigned[*it]);
      }
    }
    {
      auto it = turned_on.find(p);
      ++it;
      while (it != turned_on.end() && assigned[*it] <= 3) {
        right_neighbors.push_back(assigned[*it]);
        ++it;
      }
    }
    set<int> neighbors;
    neighbors.insert(left_neighbors.begin(), left_neighbors.end());
    neighbors.insert(right_neighbors.begin(), right_neighbors.end());
    if (neighbors.size() == 3) {
      neighbors = set<int>();
      assert(left_neighbors.size() + right_neighbors.size() == 3);
      if (left_neighbors.size() > 0) {
        neighbors.insert(left_neighbors[0]);
      }
      if (right_neighbors.size() > 0) {
        neighbors.insert(right_neighbors[0]);
      }
    }
    if (!neighbors.count(1)) {
      assigned[p] = 1;
    } else if (!neighbors.count(2)) {
      assigned[p] = 2;
    } else {
      assigned[p] = 3;
    }
  }
  return assigned;
}
bool is_good(vector<int>::iterator current_begin,
             vector<int>::iterator current_end) {
  if ((int)(current_end - current_begin) <= 1) {
    return true;
  }
  int highest = *max_element(current_begin, current_end);
  for (int j = highest; j >= highest - 2; --j) {
    auto hi_it = find(current_begin, current_end, j);
    if (hi_it == current_end) {
      continue;
    }
    auto next_hi = find(hi_it + 1, current_end, j);
    if (next_hi == current_end) {
      return is_good(current_begin, hi_it) && is_good(hi_it + 1, current_end);
    }
  }
  return false;
}
bool is_good(vector<int> current) {
  return is_good(current.begin(), current.end());
}
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
auto rng = default_random_engine(seed1);
void solve() {
  int n;
  cin >> n;
  vector<int> ps(n);
  for (int& p : ps) {
    cin >> p;
    --p;
  }
  vector<int> result = solve(ps);
  assert(*max_element(result.begin(), result.end()) <= 24);
  for (int r : result) {
    cout << r << " ";
  }
  cout << "\n";
  vector<int> turned_on(n, -1);
  for (int i = 0; i < n; ++i) {
    turned_on[ps[i]] = result[ps[i]];
    vector<int> current;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int num_test_cases;
  cin >> num_test_cases;
  for (int test_case_num = 1; test_case_num <= num_test_cases;
       ++test_case_num) {
    solve();
  }
  return 0;
}