#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const int N = 2e5 + 5;
int n;
int a[N];
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<int> dist(n + 1);
  queue<int> q;
  q.emplace(1);
  for (int i = 2; i <= n; i++) {
    if (a[i] < a[i - 1]) q.pop();
    dist[a[i]] = dist[q.front()] + 1;
    q.emplace(a[i]);
  }
  cout << *max_element(dist.begin(), dist.end()) << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc;
  cin >> tc;
  for (int T = 1; T <= tc; T++) {
    solve();
  }
  return 0;
}
