#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tt;
  cin >> tt;
  while (tt--) {
    int n, ans = 1;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; ++i) cin >> i[arr];
    queue<int> q;
    q.push(1);
    int depth[n + 1];
    depth[1] = 0;
    for (int i = 1; i < n; ++i) {
      q.push(i[arr]);
      if (i[arr] < arr[i - 1]) q.pop();
      depth[i[arr]] = depth[q.front()] + 1;
    }
    cout << *max_element(depth + 1, depth + n + 1) << '\n';
  }
  return 0;
}
