#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int main() {
  int t, n, a, last, mx, s;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    queue<int> q;
    last = -1, mx = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a);
      if (i == 0)
        q.push(0);
      else {
        if (a < last || i == 1) {
          s = q.front() + 1;
          q.pop();
          q.push(s);
          mx = max(mx, s);
        } else {
          s = q.front();
          q.push(s);
        }
      }
      last = a;
    }
    printf("%d\n", mx);
  }
  return 0;
}
