#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int bfs(vector<vector<long long int> > &gr,
                  vector<long long int> &dist) {
  queue<long long int> q;
  q.push(0);
  long long int maxy = 1;
  dist[0] = 1;
  while (!q.empty()) {
    long long int vv = q.front(), sz = gr[vv].size();
    q.pop();
    for (long long int i = 0; i < sz; i++) {
      q.push(gr[vv][i]);
      dist[gr[vv][i]] = dist[vv] + 1;
      maxy = max(maxy, dist[gr[vv][i]]);
    }
  }
  return maxy;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> vec(n);
    for (long long int i = 0; i < n; i++) cin >> vec[i];
    vector<vector<long long int> > gr(n);
    long long int i = 1, pr = 0;
    while (i < n) {
      while (i < n - 1 && vec[i] <= vec[i + 1]) {
        gr[vec[pr] - 1].push_back(vec[i] - 1);
        i++;
      }
      gr[vec[pr] - 1].push_back(vec[i] - 1);
      i++;
      pr++;
    }
    vector<long long int> dist(n, 0);
    long long int ans = bfs(gr, dist);
    ans--;
    cout << ans << "\n";
  }
  return 0;
}
