Problem: One Saturday afternoon Egor was playing his favorite RPG game. While discovering new lands and territories, he came across the following sign:

<image>

Egor is a passionate player, but he is an algorithmician as well. That's why he instantly spotted four common letters in two words on the sign above — if we permute the letters "R", "E", "G", "O" from the first word, we can obtain the letters "O", "G", "R", "E". Egor got inspired by the sign and right away he came up with a problem about permutations.

You are given a permutation of length n. You have to split it into some non-empty subsequences so that each element of the permutation belongs to exactly one subsequence. Each subsequence must be monotonic — that is, either increasing or decreasing.

Sequence is called to be a subsequence if it can be derived from permutation by deleting some (possibly none) elements without changing the order of the remaining elements.

The number of subsequences should be small enough — let f(n) be the minimum integer k such that every permutation of length n can be partitioned into at most k monotonic subsequences.

You need to split the permutation into at most f(n) monotonic subsequences.

Input

The first line contains one integer t (1 ≤ t ≤ 10^5) — the number of test cases.

You can only use t = 1 in hacks.

Next, descriptions of t test cases come, each of them in the following format.

The first line of a single test case contains one integer n (1 ≤ n ≤ 10^5) — the length of the permutation. The second line contains n distinct integers a_i (1 ≤ a_i ≤ n) — the permutation itself.

The sum of the values of n over all test cases doesn't exceed 10^5.

Output

For each test case print the answer in the following format:

In the first line print k (1 ≤ k ≤ f(n)) — the number of the subsequences in the partition. In the next k lines, print the descriptions of found subsequences. Each description should start with a number l_i (1 ≤ l_i ≤ n) — the length of the corresponding subsequence, followed by l_i integers — the values of this subsequence in the order in which they occur in the permutation.

Each subsequence you output must be either increasing or decreasing. 

In case there are multiple possible answers, print any of them.

Example

Input


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


Output


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

Note

In the example, we can split:

  * [4, 3, 1, 2] into [4, 3, 1], [2] 
  * [4, 5, 6, 1, 3, 2] into [4, 1], [5, 6] and [3, 2] 
  * [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] into [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 



Surely, there are many more answers possible.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <typename... As>
struct tpl : public std::tuple<As...> {
  using std::tuple<As...>::tuple;
  tpl() {}
  tpl(std::tuple<As...> const& b) { std::tuple<As...>::operator=(b); }
  template <typename T = tuple<As...> >
  typename tuple_element<0, T>::type const& x() const {
    return get<0>(*this);
  }
  template <typename T = tuple<As...> >
  typename tuple_element<0, T>::type& x() {
    return get<0>(*this);
  }
  template <typename T = tuple<As...> >
  typename tuple_element<1, T>::type const& y() const {
    return get<1>(*this);
  }
  template <typename T = tuple<As...> >
  typename tuple_element<1, T>::type& y() {
    return get<1>(*this);
  }
  template <typename T = tuple<As...> >
  typename tuple_element<2, T>::type const& z() const {
    return get<2>(*this);
  }
  template <typename T = tuple<As...> >
  typename tuple_element<2, T>::type& z() {
    return get<2>(*this);
  }
  template <typename T = tuple<As...> >
  typename tuple_element<3, T>::type const& w() const {
    return get<3>(*this);
  }
  template <typename T = tuple<As...> >
  typename tuple_element<3, T>::type& w() {
    return get<3>(*this);
  }
};
using lli = int;
using llu = long long unsigned;
using pii = tpl<lli, lli>;
using piii = tpl<lli, lli, lli>;
using piiii = tpl<lli, lli, lli, lli>;
using vi = vector<lli>;
using vii = vector<pii>;
using viii = vector<piii>;
using vvi = vector<vi>;
using vvii = vector<vii>;
using vviii = vector<viii>;
template <class T>
using min_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T>
using max_queue = priority_queue<T>;
template <size_t... I>
struct my_index_sequence {
  using type = my_index_sequence;
  static constexpr array<size_t, sizeof...(I)> value = {{I...}};
};
namespace my_index_sequence_detail {
template <typename I, typename J>
struct concat;
template <size_t... I, size_t... J>
struct concat<my_index_sequence<I...>, my_index_sequence<J...> >
    : my_index_sequence<I..., (sizeof...(I) + J)...> {};
template <size_t N>
struct make_index_sequence
    : concat<typename make_index_sequence<N / 2>::type,
             typename make_index_sequence<N - N / 2>::type>::type {};
template <>
struct make_index_sequence<0> : my_index_sequence<> {};
template <>
struct make_index_sequence<1> : my_index_sequence<0> {};
}  // namespace my_index_sequence_detail
template <class... A>
using my_index_sequence_for =
    typename my_index_sequence_detail::make_index_sequence<sizeof...(A)>::type;
template <class T, size_t... I>
void print_tuple(ostream& s, T const& a, my_index_sequence<I...>) {
  using swallow = int[];
  (void)swallow{0, (void(s << (I == 0 ? "" : ", ") << get<I>(a)), 0)...};
}
template <class T>
ostream& print_collection(ostream& s, T const& a);
template <class... A>
ostream& operator<<(ostream& s, tpl<A...> const& a);
template <class... A>
ostream& operator<<(ostream& s, tuple<A...> const& a);
template <class A, class B>
ostream& operator<<(ostream& s, pair<A, B> const& a);
template <class T, size_t I>
ostream& operator<<(ostream& s, array<T, I> const& a) {
  return print_collection(s, a);
}
template <class T>
ostream& operator<<(ostream& s, vector<T> const& a) {
  return print_collection(s, a);
}
template <class T, class U>
ostream& operator<<(ostream& s, multimap<T, U> const& a) {
  return print_collection(s, a);
}
template <class T>
ostream& operator<<(ostream& s, multiset<T> const& a) {
  return print_collection(s, a);
}
template <class T, class U>
ostream& operator<<(ostream& s, map<T, U> const& a) {
  return print_collection(s, a);
}
template <class T>
ostream& operator<<(ostream& s, set<T> const& a) {
  return print_collection(s, a);
}
template <class T>
ostream& print_collection(ostream& s, T const& a) {
  s << '[';
  for (auto it = begin(a); it != end(a); ++it) {
    s << *it;
    if (it != prev(end(a))) s << " ";
  }
  return s << ']';
}
template <class... A>
ostream& operator<<(ostream& s, tpl<A...> const& a) {
  s << '(';
  print_tuple(s, a, my_index_sequence_for<A...>{});
  return s << ')';
}
template <class... A>
ostream& operator<<(ostream& s, tuple<A...> const& a) {
  s << '(';
  print_tuple(s, a, my_index_sequence_for<A...>{});
  return s << ')';
}
template <class A, class B>
ostream& operator<<(ostream& s, pair<A, B> const& a) {
  return s << "(" << get<0>(a) << ", " << get<1>(a) << ")";
}
struct BIT {
  vii A;
  BIT(lli n) : A(n + 1, pii(0, -1)) {}
  pii get(lli i) {
    i += 1;
    pii r = pii(0, -1);
    for (; i > 0; i -= i & -i) {
      r = max(r, A[i]);
    }
    return r;
  }
  void add(lli i, pii v) {
    i += 1;
    for (; i < (lli)A.size(); i += i & -i) {
      A[i] = max(A[i], v);
    }
  }
};
void solve() {
  int n;
  cin >> n;
  vi A(n);
  for (lli i = 0; i < (lli)(n); ++i) cin >> A[i];
  for (lli i = 0; i < (lli)(n); ++i) A[i] -= 1;
  vi I(n);
  iota(begin(I), end(I), 0);
  vvi ans;
  while (!I.empty()) {
    BIT b(n + 1);
    vi from(I.size());
    vi sz(I.size());
    int k = 0;
    while ((int)I.size() >= ((k + 1) * (k + 2)) / 2) k += 1;
    for (lli i = 0; i < (lli)((int)I.size()); ++i) {
      int p, q;
      tie(p, q) = b.get(A[I[i]]);
      from[i] = q;
      sz[i] = p;
      b.add(A[I[i]] + 1, pii(p + 1, i));
    }
    int j = 0;
    for (lli k = 0; k < (lli)(I.size()); ++k)
      if (sz[k] > sz[j]) j = k;
    if (sz[j] >= k) {
      vi R;
      while (j != -1) {
        R.push_back(A[I[j]] + 1);
        j = from[j];
      }
      ans.push_back(R);
      reverse(begin(ans.back()), end(ans.back()));
      vi J;
      for (int x : I) {
        if (!R.empty() && A[x] + 1 == R.back())
          R.pop_back();
        else
          J.push_back(x);
      }
      I = J;
    } else {
      vvi O(k + 1);
      for (lli i = 0; i < (lli)(I.size()); ++i) O[sz[i]].push_back(A[I[i]] + 1);
      for (lli i = 0; i < (lli)(k + 1); ++i)
        if (!O[i].empty()) ans.push_back(O[i]);
      I = vi();
    }
  }
  cout << ans.size() << '\n';
  for (auto v : ans) {
    cout << v.size();
    for (auto x : v) cout << ' ' << x;
    cout << '\n';
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  for (lli i = 0; i < (lli)(t); ++i) solve();
  cout << flush;
  return 0;
}