#include <bits/stdc++.h>
using namespace std;
int ri() {
  int x;
  if (scanf(" %d", &x) == EOF) return -1;
  return x;
}
long long int rl() {
  long long int x;
  if (cin >> x) return x;
  return -1;
}
string rs() {
  string s;
  if (cin >> s) return s;
  return "";
}
struct SingleCase {
  int n;
  bool solveCase() {
    n = ri();
    if (n < 0) return false;
    vector<int> v;
    for (int i = 0; i < n; ++i) v.push_back(ri());
    int ret = 0;
    int vertices = 1;
    queue<int> heights;
    heights.push(0);
    int next = 1;
    while (vertices > 0) {
      vertices--;
      int h = heights.front();
      heights.pop();
      ret = max(ret, h);
      int j = next - 1;
      while (j + 1 < n && j + 1 == next || v[j + 1] > v[j]) j++;
      int children = (j - next + 1);
      next = j + 1;
      for (int i = 0; i < children; ++i) {
        vertices++;
        heights.push(h + 1);
      }
    }
    cout << ret << endl;
    return true;
  }
};
int main() {
  ri();
  while (SingleCase().solveCase()) {
  };
  return 0;
}
