#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5;
long long t, n, a[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (long long i = 0; i < n; i++) cin >> a[i];
    deque<long long> d(1, 0);
    long long p = n + 1;
    for (long long i = 1; i < n; i++) {
      if (a[i] > p)
        d.push_back(d.back());
      else
        d.push_back(d.front() + 1), d.pop_front();
      p = a[i];
    }
    cout << d.back() << '\n';
  }
}
