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 MX = 8500 + 100;
int p[MX], dajodaw[MX];
int ans[MX];
int last_color = 24;
void solve(const vector<int>& vec) {
  set<int> marked;
  vector<int> rec;
  if (vec.size() > 4) {
    for (size_t i = 0; i < vec.size();) {
      int special;
      if (i + 2 < vec.size()) {
        const int mTime =
            min(min(dajodaw[vec[i]], dajodaw[vec[i + 1]]), dajodaw[vec[i + 2]]);
        if (dajodaw[vec[i]] == mTime) {
          special = vec[i];
        } else if (dajodaw[vec[i + 1]] == mTime) {
          special = vec[i + 1];
        } else {
          special = vec[i + 2];
        }
        i += 3;
      } else if (i + 1 < vec.size()) {
        if (dajodaw[vec[i]] < dajodaw[vec[i + 1]]) {
          special = vec[i];
        } else {
          special = vec[i + 1];
        }
        i += 2;
      } else {
        special = vec[i];
        i++;
      }
      rec.push_back(special);
      marked.insert(special);
    }
    solve(rec);
  }
  {
    static int colors[3];
    colors[0] = last_color;
    colors[1] = last_color - 1;
    colors[2] = last_color - 2;
    last_color -= 3;
    vector<pair<int, int>> events;
    for (const auto x : vec) {
      events.emplace_back(dajodaw[x], x);
    }
    sort(events.begin(), events.end());
    map<int, int> places;
    for (const auto x : events) {
      const int v = x.second;
      if (marked.count(v) == 1) {
        places[v] = -1;
        continue;
      }
      vector<int> ids;
      places[v] = x.first;
      auto it = places.find(v);
      auto fst = it;
      auto lst = it;
      while (fst != places.begin()) {
        auto prev = fst;
        prev--;
        if ((*prev).second == -1) {
          break;
        } else {
          fst = prev;
        }
      }
      while (true) {
        auto next = lst;
        next++;
        if (next == places.end()) break;
        if ((*next).second == -1) {
          break;
        } else {
          lst = next;
        }
      }
      lst++;
      for (auto r = fst; r != lst; r++) {
        ids.push_back((*r).first);
      }
      bool done = false;
      for (int nc = 0; nc < 3; nc++) {
        bool ok = true;
        if (ids.size() <= 3) {
          for (size_t xx = 0; xx < ids.size(); xx++) {
            if (ids[xx] != v) {
              if (colors[nc] == ans[ids[xx]]) ok = false;
            }
          }
        } else {
          for (size_t prev = 0; prev + 1 < ids.size(); prev++) {
            if (ids[prev + 1] == v) {
              if (ans[ids[prev]] == colors[nc]) ok = false;
            }
          }
          for (size_t next = 1; next < ids.size(); next++) {
            if (ids[next - 1] == v) {
              if (ans[ids[next]] == colors[nc]) ok = false;
            }
          }
        }
        if (ok) {
          done = true;
          ans[v] = colors[nc];
          break;
        }
      }
      assert(done);
      places[v] = 1;
    }
  }
}
void stress(int n) {
  static bool enabled[MX];
  memset(enabled, 0, sizeof(bool) * (n + 1));
  vector<int> res;
  for (int en = 1; en <= n; en++) {
    enabled[p[en]] = true;
    res.clear();
    for (int i = 1; i <= n; i++) {
      if (enabled[i]) res.push_back(ans[i]);
    }
    for (size_t left = 0; left < res.size(); left++) {
      set<int> unique;
      set<int> broken;
      for (size_t right = left; right < res.size(); right++) {
        const int tmp = res[right];
        if (broken.count(tmp) != 0) continue;
        if (unique.count(tmp) != 0) {
          unique.erase(tmp);
          broken.insert(tmp);
        } else {
          unique.insert(tmp);
        }
        if (unique.empty()) {
          cout << endl;
          cout << "moment: " << en << endl;
          cout << left << ".." << right << endl;
          for (size_t x = left; x <= right; x++) {
            cout << res[x] << " ";
          }
          cout << endl;
          exit(0);
        }
      }
    }
  }
}
void solve() {
  int n;
  ignore = scanf("%d", &n);
  memset(ans, 0, sizeof(int) * (n + 1));
  last_color = 24;
  for (int i = 1; i <= n; i++) {
    ignore = scanf("%d", &p[i]);
    dajodaw[p[i]] = i;
  }
  vector<int> loc;
  for (int i = 1; i <= n; i++) {
    loc.push_back(i);
  }
  solve(loc);
  for (int i = 1; i <= n; i++) {
    assert(ans[i] >= 1 && ans[i] <= 24);
    printf("%d ", ans[i]);
  }
  printf("\n");
  return;
}
int main() {
  int t;
  ignore = scanf("%d", &t);
  while (t--) {
    solve();
  }
}