#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 300;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);
const double TAU = 2 * PI;
int n;
int a[N];
vector<int> leafs;
int p[N], depth[N];
int dfs(int node) {
  if (node == 0) return 0;
  if (node == 1) return 0;
  if (depth[node]) return depth[node];
  return depth[node] = 1 + dfs(p[node]);
}
void solve() {
  cin >> n;
  leafs.clear();
  for (int i = 1; i <= n; i++) p[i] = depth[i] = 0;
  leafs.push_back(1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cur = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i - 1]) {
      p[a[i]] = leafs[cur];
    } else {
      cur++;
      p[a[i]] = leafs[cur];
    }
    leafs.push_back(a[i]);
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    dfs(i);
    mx = max(mx, depth[i]);
  }
  cout << mx << endl;
}
signed main() {
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
