#include <bits/stdc++.h>
using namespace std;
int parent[200005], a[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t, n, i, j;
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 1; i <= n; i++) cin >> a[i];
    vector<int> v;
    v.push_back(a[1]);
    parent[a[2]] = a[1];
    v.push_back(a[2]);
    j = 0;
    for (i = 3; i <= n; i++) {
      v.push_back(a[i]);
      if (a[i] < a[i - 1]) j++;
      parent[a[i]] = v[j];
    }
    int now = a[n];
    int ans = 0;
    while (now != a[1]) {
      ans++;
      now = parent[now];
    }
    cout << ans << endl;
  }
}
