#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  reverse(v.begin(), v.end());
  int root = v.back();
  v.pop_back();
  int depth[n + 10], par[n + 10];
  memset(depth, 0, sizeof(depth)), memset(par, 0, sizeof(par));
  depth[root] = par[root] = 0;
  queue<int> q;
  q.push(root);
  int ans = 0;
  while (!q.empty()) {
    int u = q.front();
    ans = max(ans, depth[u]);
    q.pop();
    int last = 0;
    while (v.size() and v.back() > last) {
      int x = v.back();
      v.pop_back();
      par[x] = u;
      depth[x] = depth[u] + 1;
      q.push(x);
      last = x;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
