t = int(input())
while(t > 0):
n = int(input())
a = list(map(int, input().split()))
grafo = [1, 1]
i = 2
j = 1
while(i < n):
filho = a[i-1]
if(a[i] < filho):
grafo.append(1)
j += 1
else:
grafo[j] += 1
i += 1
i = 0
s = 0
lim = 1
prof = 0
while(i < j):
if(i+lim <= j):
for k in range(i, i+lim):
s += grafo[k]
prof += 1
i += lim
lim = s
s = 0
print(prof)
t -= 1
# include <bits/stdc++.h>
# define ll long long
# define all(x) x.begin(),x.end()
using namespace std;
void solve() {
int n , par = 0 ; cin >> n ;
vector<int> p(n) , dis(n, 1e6) ;
for (int i = 0; i < n; ++i) {
cin >> p[i] ;
p[i]-- ;
}
vector<vector<int>> G(n) ;
int last = p[1] ;
G[p[par]].push_back(last) ;
for (int i = 2; i < n; ++i) {
if (p[i] < last ){
par++ ;
}
G[p[par]].push_back(p[i]) ;
last = p[i] ;
}
queue<int> q ;
dis[0] = 0 ;
q.push(0) ;
while ( !q.empty() ){
auto cur = q.front() ;
q.pop() ;
for ( auto &v : G[cur] ){
if ( dis[v] > dis[cur] + 1 ){
dis[v] = dis[cur] + 1 ;
q.push(v) ;
}
}
}
cout << *max_element(all(dis)) << '\n' ;
}
int main() {
cin.tie(nullptr), cout.tie(nullptr), iostream::sync_with_stdio(false) ;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int t = 1; cin >> t ;
while (t--)
solve();
return 0;
}
377. Combination Sum IV | 322. Coin Change |
307. Range Sum Query - Mutable | 287. Find the Duplicate Number |
279. Perfect Squares | 275. H-Index II |
274. H-Index | 260. Single Number III |
240. Search a 2D Matrix II | 238. Product of Array Except Self |
229. Majority Element II | 222. Count Complete Tree Nodes |
215. Kth Largest Element in an Array | 198. House Robber |
153. Find Minimum in Rotated Sorted Array | 150. Evaluate Reverse Polish Notation |
144. Binary Tree Preorder Traversal | 137. Single Number II |
130. Surrounded Regions | 129. Sum Root to Leaf Numbers |
120. Triangle | 102. Binary Tree Level Order Traversal |
96. Unique Binary Search Trees | 75. Sort Colors |
74. Search a 2D Matrix | 71. Simplify Path |
62. Unique Paths | 50. Pow(x, n) |
43. Multiply Strings | 34. Find First and Last Position of Element in Sorted Array |