#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T> readArray(int s) {
  vector<T> arr(s);
  for (int i = 0; i < s; i++) {
    cin >> arr[i];
  }
  return arr;
}
template <typename T>
void printArray(vector<T> arr, char delimitter) {
  for (int i = 0; i < arr.size(); i++) {
    cout << arr[i] << delimitter;
  }
  cout << endl;
}
int inf = pow(10, 9);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<int> arr = readArray<int>(n);
    queue<pair<int, int>> q;
    q.push(make_pair(1, 0));
    int prev = 1;
    for (int i = 1; i < n; ++i) {
      if (arr[i] < prev) {
        q.pop();
      }
      q.push(make_pair(arr[i], q.front().second + 1));
      prev = arr[i];
    }
    cout << q.back().second << endl;
  }
  return 0;
}
