#include <bits/stdc++.h>
#pragma GCC optimize(2)
const double esp = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int inf = 1e9;
using namespace std;
long long read() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int t;
const int N = 2e5 + 10;
int a[N];
int n;
int check(int pos) {
  int minn = a[pos];
  int ans = 0;
  for (int i = pos; i <= n + 1; i++) {
    if (minn > a[i]) {
      ans = i;
      break;
    }
    minn = a[i];
  }
  return ans - 1;
}
int h[N];
int main() {
  t = read();
  while (t--) {
    n = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    for (int i = 1; i <= n; i++) h[i] = 0;
    a[n + 1] = -1;
    int minn = 1;
    int pos = 0;
    pos = check(2);
    int c = pos - 1;
    queue<int> q;
    for (int i = 2; i <= pos; i++) {
      q.push(i);
      h[a[i]] = 1;
    }
    while (q.size() && pos != n) {
      int top = q.front();
      q.pop();
      int temp = check(pos + 1);
      for (int j = pos + 1; j <= temp; j++) {
        h[a[j]] = h[a[top]] + 1;
        q.push(j);
      }
      pos = temp;
      if (pos == n) break;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) ans = max(ans, h[i]);
    printf("%d\n", ans);
  }
  return 0;
}
