#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
long long d[N], a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  if (fopen("A.inp", "r")) {
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    queue<long long> q;
    for (int i = 1; i <= n; i++) d[i] = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    q.push(1);
    d[1] = 0;
    long long now = 2;
    while (q.size()) {
      long long x = q.front();
      q.pop();
      long long last = 0;
      while (now <= n) {
        if (a[now] < last) break;
        d[a[now]] = d[x] + 1;
        last = a[now];
        q.push(a[now]);
        now++;
      }
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) ans = max(ans, d[i]);
    cout << ans << '\n';
  }
}
