#include <bits/stdc++.h>
using namespace std;
int dfs(int v, const vector<vector<int>>& gr) {
  int ans = 0;
  for (auto i : gr[v]) {
    ans = max(dfs(i, gr), ans);
  }
  return ans + 1;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]--;
  }
  int i = 1;
  vector<int> maxes(n, 0);
  vector<vector<int>> gr(n);
  queue<int> q;
  q.push(0);
  while (i < n && !q.empty()) {
    int x = q.front();
    q.pop();
    while (i < n && a[i] > maxes[x]) {
      gr[x].push_back(a[i]);
      maxes[x] = max(maxes[x], a[i]);
      q.push(a[i]);
      ++i;
    }
  }
  int minn = 0;
  for (auto i : gr[0]) {
    minn = max(minn, dfs(i, gr));
  }
  printf("%d\n", minn);
  return;
}
int main() {
  int tt = 1;
  cin >> tt;
  while (tt--) solve();
}
