#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void prn(Arg1&& arg1) {
  cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prn(args...);
}
template <typename Arg1>
void prs(Arg1&& arg1) {
  cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prs(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
  cin >> arg1;
  read(args...);
}
const int N = 2e5 + 1;
int depth[N], par[N];
int n;
vector<int> vec;
void solve() {
  read(n);
  vec.resize(n);
  for (int i = 0; i < n; ++i) {
    read(vec[i]);
  }
  int ans = 0;
  queue<int> q;
  q.push(1);
  depth[1] = 0;
  int lastChild = -1;
  vec.erase(vec.begin());
  for (auto cur : vec) {
    if (cur > lastChild) {
      par[cur] = q.front();
      lastChild = cur;
      depth[cur] = depth[par[cur]] + 1;
      ans = max(ans, depth[cur]);
      q.push(cur);
      continue;
    }
    q.pop();
    lastChild = cur;
    par[cur] = q.front();
    depth[cur] = depth[par[cur]] + 1;
    ans = max(ans, depth[cur]);
    q.push(cur);
  }
  prn(ans);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  read(t);
  for (int tc = 1; tc <= t; ++tc) {
    solve();
  }
  return 0;
}
