#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int> > q;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, x;
    scanf("%d", &n);
    int ans = 0;
    while (!q.empty()) q.pop();
    scanf("%d", &x);
    q.push({x, 0});
    for (int i = 2; i <= n; ++i) {
      scanf("%d", &x);
      if (q.size() == 1) {
        q.push({x, q.front().second + 1});
      } else {
        if (q.back().first > x) q.pop();
        q.push({x, q.front().second + 1});
      }
      ans = max(ans, q.back().second);
    }
    printf("%d\n", ans);
  }
}
