#include <bits/stdc++.h>
using namespace std;
int height[200005], n, node1, node2, t;
queue<int> q;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) height[i] = 0;
    while (!q.empty()) q.pop();
    cin >> node1;
    q.push(node1);
    while (--n) {
      cin >> node2;
      if (node1 > node2) q.pop();
      height[node2] = height[q.front()] + 1;
      q.push(node2);
      node1 = node2;
    }
    cout << height[node1] << "\n";
  }
}
