#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int M = 1024;
const int MD = 1e9 + 7;
int n, m, k;
int a, b, r;
vector<int> g[N];
vector<int> v;
int dp[N];
int par[N];
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    cin >> n;
    v.resize(n);
    for (int i = 1; i <= n; i++) g[i].clear();
    int last = 0;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      if (i) {
        if (v[i] > v[i - 1])
          g[v[last]].push_back(v[i]);
        else
          g[v[++last]].push_back(v[i]);
      }
    }
    queue<int> q;
    q.push(1);
    dp[1] = 0;
    int ans = 0;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int w : g[u]) {
        q.push(w);
        ans = dp[w] = dp[u] + 1;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
