#include <bits/stdc++.h>
using namespace std;
int getHeight(int n, int arr[]) {
  if (n == 1) return 0;
  int sizeprev = 1, height = 0;
  int thisnode = arr[0];
  int cursize = 0, vis[n];
  memset(vis, 0, sizeof vis);
  vis[1] = 1;
  for (int i = 1; i < n; i++) {
    if (i == 1) {
      cursize = 1;
      height = 1;
      sizeprev--;
      thisnode = arr[1];
    } else if (arr[i] > thisnode) {
      if (!vis[height]) {
        sizeprev--;
        vis[height] = 1;
        cursize = 0;
      }
      cursize++;
      thisnode = arr[i];
    } else if (arr[i] < thisnode) {
      if (sizeprev) {
        cursize++;
        sizeprev--;
        thisnode = arr[i];
      } else {
        sizeprev = cursize;
        cursize = 1;
        height++;
        thisnode = arr[i];
        vis[height] = 1;
        sizeprev--;
      }
    }
  }
  return height;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    if (n == 1)
      cout << 0 << endl;
    else
      cout << getHeight(n, arr) << endl;
  }
  return 0;
}
