//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
      I ♥ CLARICE STARLING...
        EXPLAINATION BELOW->
        BFS
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,i,j,d=0;cin>>n;
    int a[n];fo(i,0,n)cin>>a[i];

    vector<int>seg;seg.pb(1);
    i=j=1;
    while(j<n)
    {
        j=i+1;
        while(j<n&&a[j]>a[j-1])j++;
        seg.pb(j-i);
        i=j;
    }

    //for(auto it:seg)cout<<it<<" ";
    //cout<<"\n";
    j=0;
    int parent=0;
    while(j<sz(seg)-1)
    {
        d++;
        j+=seg[parent++];
        //cout<<j-seg[parent-1]<<" "<<j<<"\n";
    }
    cout<<d<<"\n";

}
int main()
{
   fastio
   Test_cases
   solve();
  return 0;
}
//Don't use memset
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>;
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.

//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
      I ♥ CLARICE STARLING...
        EXPLAINATION BELOW->
        BFS
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,i,j,d=0;cin>>n;
    int a[n];fo(i,0,n)cin>>a[i];

    vector<int>seg;seg.pb(1);
    i=j=1;
    while(j<n)
    {
        j=i+1;
        while(j<n&&a[j]>a[j-1])j++;
        seg.pb(j-i);
        i=j;
    }

    j=0;
    int parent=0;
    int loop=1;
    while(j<sz(seg)-1)
    {
        if(loop==0)loop=seg[++parent];
        j++;
        d++;
        loop--;
    }
    cout<<d<<"\n";

}
int main()
{
   fastio
   Test_cases
   solve();
  return 0;
}
//Don't use memset
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>;
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.

//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


#include<bits/stdc++.h>

using namespace std;

#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define sz(a) int((a).size())

#define x first
#define y second

typedef long long li;
typedef pair<int, int> pt;

const int INF = int(1e9);
const li INF64 = li(1e18);

int n;
vector<int> a;

inline bool read() {
	if(!(cin >> n))
		return false;
	a.resize(n);
	fore (i, 0, n)
		cin >> a[i];
	return true;
}

inline void solve() {
	vector<int> h(n, INF);
	h[0] = 0;
	int lst = 0;
	fore (i, 1, n) {
		if (i - 1 > 0 && a[i - 1] > a[i])
			lst++;
		h[i] = h[lst] + 1;
	}
	cout << h[n - 1] << endl;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	int tt = clock();
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);

	int tc; cin >> tc;
	while(tc--) {
		read();
		solve();

#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	return 0;
}


//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
      I ♥ CLARICE STARLING...
        EXPLAINATION BELOW->
        BFS
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,i,d=0;cin>>n;
    int a[n];fo(i,0,n)cin>>a[i];

    int j,loop=0;
    i=1;
    queue<int>parent;
    while(j<n)
    {
        j=i+1;
        while(j<n&&a[j]>a[j-1])j++;
        parent.push(j-i);
       // cout<<(j-i)<<" "<<loop<<" "<<d<<"\n";
        if(loop==0)
        {
            d++;
            loop=parent.front();
            parent.pop();
        }
        loop--;
        i=j;
    }
    cout<<d<<"\n";

}
int main()
{
   fastio
   Test_cases
   solve();
  return 0;
}
//Don't use memset
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>;
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.

//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
      I ♥ CLARICE STARLING...
        EXPLAINATION BELOW->
        BFS
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,i;cin>>n;
    int a[n];fo(i,0,n)cin>>a[i];

    int depth[n],parent=0;depth[0]=0;
    for(i=1;i<n;i++)
    {
        if((i-1>0)&&(a[i-1]>a[i]))parent++;
        depth[i]=depth[parent]+1;
    }
    cout<<depth[n-1]<<"\n";
}
int main()
{
   fastio
   Test_cases
   solve();
  return 0;
}
//Don't use memset
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>;
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.

//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
      I ♥ CLARICE STARLING...
        EXPLAINATION BELOW->
        BFS
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,i,j,d=0;cin>>n;
    int a[n];fo(i,0,n)cin>>a[i];

    vector<int>seg;seg.pb(1);
    i=j=1;
    while(j<n)
    {
        j=i+1;
        while(j<n&&a[j]>a[j-1])j++;
        seg.pb(j-i);
        i=j;
    }

    j=0;
    while(j<sz(seg)-1)
    {
        j=seg[j]+j;
        d++;
    }
    //if(d!=0)d--;
    cout<<d<<"\n";

}
int main()
{
   fastio
   Test_cases
   solve();
  return 0;
}
//Don't use memset
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>;
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.

//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+5];
        fr(i,0,n)cin>>a[i];
        ll v[n+5]={0};
        v[0]=0;
        ll pos=0;

        fr(i,1,n)
        {
            if(a[i-1]>a[i])pos++;
            v[i]=v[pos]+1;
        }

        cout<<v[n-1]<<endl;

    }

}


#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+5];
        fr(i,0,n)cin>>a[i];
        vi v;
        v.pb(1);
        ll cnt=1;
        fr(i,2,n)
        {
            if(a[i-1]<a[i])cnt++;
            else { v.pb(cnt);cnt=1; }
        }
        v.pb(cnt);
        sort(v.begin()+1,v.end(),greater<ll>());

       //for(auto x:v)cout<<x<<" ";cout<<endl;

        ll i=1,ans=0;
        queue<ll>q;
        q.push(1);
        ll x=q.front();
        while(i<v.size())
        {
            ll s=q.front();
            ans++;
            fr(j,0,s){ q.push(v[i]); i++; q.front()--; if(i>=v.size())break; }
           // what(q.front());
            //if(q.front()==0)
            x=q.front();
            q.pop();
        }

        //if(x==0)ans--;

        cout<<ans<<endl;

    }

}


#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+5];
        fr(i,0,n)cin>>a[i];
        vi v;
        v.pb(1);
        ll cnt=1;
        fr(i,2,n)
        {
            if(a[i-1]<a[i])cnt++;
            else { v.pb(cnt);cnt=1; }
        }
        v.pb(cnt);

       for(auto x:v)cout<<x<<" ";cout<<endl;

        ll i=1,ans=0;
        queue<ll>q;
        q.push(1);
        ll x=q.front();
        while(i<v.size())
        {
            ll s=q.front();
            ans++;
            fr(j,0,s){ q.push(v[i]); i++; q.front()--; if(i>=v.size())break; }
           // what(q.front());
            //if(q.front()==0)
            x=q.front();
            q.pop();
        }

        //if(x==0)ans--;

        cout<<ans<<endl;

    }

}


#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+5];
        fr(i,0,n)cin>>a[i];
        vi v;
        v.pb(1);
        ll cnt=1;
        fr(i,2,n)
        {
            if(a[i-1]<a[i])cnt++;
            else { v.pb(cnt);cnt=1; }
        }
        v.pb(cnt);

       // for(auto x:v)cout<<x<<" ";cout<<endl;

        ll i=1,ans=0;
        queue<ll>q;
        q.push(1);
        while(i<v.size())
        {
            ll s=q.front();
            ans++;
            fr(j,0,s){ q.push(v[i]); i++; q.front()--; if(i>=v.size())break; }
           // what(q.front());
            //if(q.front()==0)

            q.pop();
        }

        cout<<ans<<endl;

    }

}


#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+5];
        fr(i,0,n)cin>>a[i];
        ll v[n+5]={0};
        v[0]=0;
        ll pos=0;

        fr(i,1,n)
        {
            if(a[i-1]>a[i])pos++;
            v[i]=v[pos]+1;
        }

        ll mx=0;
        fr(i,0,n)mx=max(mx,v[i]);
        cout<<mx<<endl;

    }

}


#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+5];
        fr(i,0,n)cin>>a[i];
        vi v;
        v.pb(1);
        ll cnt=1;
        fr(i,2,n)
        {
            if(a[i-1]<a[i])cnt++;
            else { v.pb(cnt);cnt=1; }
        }
        v.pb(cnt);

       //for(auto x:v)cout<<x<<" ";cout<<endl;

        ll i=1,ans=0;
        queue<ll>q;
        q.push(1);
        ll x=q.front();
        while(i<v.size())
        {
            ll s=q.front();
            ans++;
            fr(j,0,s){ q.push(v[i]); i++; q.front()--; if(i>=v.size())break; }
           // what(q.front());
            //if(q.front()==0)
            x=q.front();
            q.pop();
        }

        //if(x==0)ans--;

        cout<<ans<<endl;

    }

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;

const int N=1e5+1;
vector<ll> a[N];
ll mx=0, node;

void dfs(ll v, ll p=-1, ll d=0){
    if(d>mx){
        mx=d;
        node=v;
    }
    for(ll u: a[v]){
        if(u==p) continue;
        dfs(u,v,d+1);
    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        for(ll i=0;i<n;i++)
            cin>>a[i];
        ll i=2, ans=1, r=1;
        while(i<n){
            ll ch=0;
            while(r--){
                while(i<n && a[i]>a[i-1]){
                    i++;
                    ch++;
                }
                //cout<<i<<" ";
                if(r==0) break;
                i++; ch++;
                if(i>=n) break;
            }
            //cout<<ch<<"\n";
            if(i>=n) break;
            r=ch+1;
            ans++;
            i++;
        }
        cout<<ans<<"\n";
    }

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n),h(n);
        for(ll i=0;i<n;i++)
            cin>>a[i];
        h[0]=0;
        h[1]=1;
        ll v=0;
        for(ll i=2;i<n;i++){
            if(a[i]<a[i-1])
                v++;
            h[i]=h[v]+1;
        }
        cout<<h[n-1]<<"\n";
    }

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        for(ll i=0;i<n;i++)
            cin>>a[i];
        ll i=2, ans=1, r=1;
        while(i<n){
            ll ch=0;
            while(r--){
                while(i<n && a[i]>a[i-1])  i++,ch++;
                if(r==0) break;
                i++; ch++;
                if(i>=n) break;
            }
            if(i>=n) break;
            r=ch+1;
            ans++;
            i++;
        }
        cout<<ans<<"\n";
    }

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n),  b;
        for(ll i=0;i<n;i++)
            cin>>a[i];
        a.pb(mod);
        ll i=1;
        b.pb(1);
        while(i<n){
            ll c=0;
            while(i<n && a[i]<a[i+1]) i++,c++;
            b.pb(c+1); i++;
        }
        ll ans=0; i=0;
        while(i<b.size()-1){
            i+=b[i];
            ans++;
        }
        cout<<ans<<"\n";
    }

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;

const int N=1e5+1;
vector<ll> a[N];
ll mx=0, node;

void dfs(ll v, ll p=-1, ll d=0){
    if(d>mx){
        mx=d;
        node=v;
    }
    for(ll u: a[v]){
        if(u==p) continue;
        dfs(u,v,d+1);
    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        for(ll i=0;i<n;i++)
            cin>>a[i];
        ll i=2, ans=1, r=1;
        while(i<n){
            ll ch=0;
            while(r--){
                while(i<n && a[i]>a[i-1]){
                    i++;
                    ch++;
                }
                //cout<<i<<" ";
                if(r==0) break;
                i++;
                if(i>=n) break;
            }
            if(i>=n) break;
            //cout<<ch<<"\n";
            r=ch+1;
            ans++;
            i++;
        }
        cout<<ans<<"\n";
    }

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        for(ll i=0;i<n;i++)
            cin>>a[i];
        ll i=1, ans=0, r=1;
        while(i<n){
            ll ch=0;
            ans++; i++;
            while(r--){
                while(i<n && a[i]>a[i-1])  i++,ch++;
                if(r==0) break;
                i++; ch++; r--;
                if(i>=n) break;
            }
            r=ch+1;
        }
        cout<<ans<<"\n";
    }

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n),  b;
        for(ll i=0;i<n;i++)
            cin>>a[i];
        a.pb(-1);
        ll i=1;
        b.pb(1);
        while(i<n){
            ll c=0;
            while(i<n && a[i]<a[i+1]) i++,c++;
            b.pb(c+1); i++;
        }
        ll ans=0; i=0;
        while(i<b.size()-1){
            i+=b[i];
            ans++;
        }
        cout<<ans<<"\n";
    }

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


/*Author-Ayush Tiwari
JAI_SHREE_RAM         */

#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)

using namespace std;
typedef long long int ll;
//-------------------------------------Mod_operations------------------------------------------
const ll M = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;
ll mod(ll x){   return (x%M);}
ll mod_minus(ll a, ll b){ ll ans= (mod(a)-mod(b)); if(ans<0) ans=mod(ans+M); return ans;}
ll mod_mul(ll a,ll b){  return mod(mod(a)*mod(b));}
ll mod_add(ll a,ll b){ return mod(mod(a)+mod(b));}
ll power(ll a,ll n){  if(n==0) return 1;  else if(n==1) return a;  ll R=power(a,n/2);  if(n%2==0) {  return R*R; }   else { return R*a*R;  }}

ll mod_div(ll a,ll b){// only if M is prime
    ll ans=mod(a);
    ll b1=power(b,M-2);
     ans= mod(mod_mul(ans,b1));
     return ans;
}

ll fact_mod(ll n){
    vll fact(n+1);
    fact[0]=1;
    for(ll i=1;i<n+1;i++){
        fact[i]=mod_mul(fact[i-1],i);
    }
    return fact[n];
}
ll nCr_mod(ll n , ll r){
    return mod( mod_mul(mod_mul(fact_mod(n),mod(fact_mod(power(r,M-2))) ),
                                       mod(power(fact_mod(n-r),M-2))   )   );
}
//-----------------------------GEOMETRY-----------------------------------------------
template<typename T>
class Cpoint
{
    public:
        T x,y,z;
    Cpoint(T tmp_x, T tmp_y=0, T tmp_z=0)
    {
        x=tmp_x;
        y=tmp_y;
        z=tmp_z;
    }

    Cpoint operator+(Cpoint b)
    {
        return Cpoint(this->x+b.x, this->y+b.y, this->z+b.z);
    }
    Cpoint operator-(Cpoint b)
    {
        return Cpoint(this->x-b.x, this->y-b.y, this->z-b.z);
    }

    Cpoint& operator+=(Cpoint b)
    {
        *this=*this+b;
        return *this;
    }
};

template<typename T>
T dot(Cpoint<T> a,Cpoint<T> b)
{
    return a.x*b.x+a.y*b.y+a.z*b.z;
}

template<typename T>
float ang(Cpoint<T> a,Cpoint<T> b)
{
    return acos(dot(a,b)/sqrt(dot(a,a)*dot(b,b)));
}
//----------------------------------------------GCD-------------------------------------------------
pair<ll,ll> Egcd(ll a,ll b)
{
  if(b==0)
    return make_pair(1,0);
  pair<ll,ll> t=Egcd(b,a%b);
  return make_pair(t.se,t.fi-(a/b)*t.se);
}
//------------------------------------------------------------------------------------------

void solve()
{
  ll n;
  cin>>n;
  ll i;
  vll a(n+1);
  for(i=0;i<n;i++)
    cin>>a[i];
  ll x=0,p=1;
  ll h=1,y=0;
  if(n==1)
  {
    cout<<0<<endl;
    return;
  }
  for(i=1;i<n;i++)
  {
    if(a[i-1]<a[i]){
      x++;
    }

    else
    {
      y++;
      if(y>=p)
      {

        h++;
        p=x;
        x=0;
        y=0;
      }
    }
  }
cout<<h<<endl;
}

int main(){
    FAST;
        #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ll t;
cin>>t;
while(t--)
solve();
}


/*Author-Ayush Tiwari
JAI_SHREE_RAM         */

#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)

using namespace std;
typedef long long int ll;
//-------------------------------------Mod_operations------------------------------------------
const ll M = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;
ll mod(ll x){   return (x%M);}
ll mod_minus(ll a, ll b){ ll ans= (mod(a)-mod(b)); if(ans<0) ans=mod(ans+M); return ans;}
ll mod_mul(ll a,ll b){  return mod(mod(a)*mod(b));}
ll mod_add(ll a,ll b){ return mod(mod(a)+mod(b));}
ll power(ll a,ll n){  if(n==0) return 1;  else if(n==1) return a;  ll R=power(a,n/2);  if(n%2==0) {  return R*R; }   else { return R*a*R;  }}

ll mod_div(ll a,ll b){// only if M is prime
    ll ans=mod(a);
    ll b1=power(b,M-2);
     ans= mod(mod_mul(ans,b1));
     return ans;
}

ll fact_mod(ll n){
    vll fact(n+1);
    fact[0]=1;
    for(ll i=1;i<n+1;i++){
        fact[i]=mod_mul(fact[i-1],i);
    }
    return fact[n];
}
ll nCr_mod(ll n , ll r){
    return mod( mod_mul(mod_mul(fact_mod(n),mod(fact_mod(power(r,M-2))) ),
                                       mod(power(fact_mod(n-r),M-2))   )   );
}
//-----------------------------GEOMETRY-----------------------------------------------
template<typename T>
class Cpoint
{
    public:
        T x,y,z;
    Cpoint(T tmp_x, T tmp_y=0, T tmp_z=0)
    {
        x=tmp_x;
        y=tmp_y;
        z=tmp_z;
    }

    Cpoint operator+(Cpoint b)
    {
        return Cpoint(this->x+b.x, this->y+b.y, this->z+b.z);
    }
    Cpoint operator-(Cpoint b)
    {
        return Cpoint(this->x-b.x, this->y-b.y, this->z-b.z);
    }

    Cpoint& operator+=(Cpoint b)
    {
        *this=*this+b;
        return *this;
    }
};

template<typename T>
T dot(Cpoint<T> a,Cpoint<T> b)
{
    return a.x*b.x+a.y*b.y+a.z*b.z;
}

template<typename T>
float ang(Cpoint<T> a,Cpoint<T> b)
{
    return acos(dot(a,b)/sqrt(dot(a,a)*dot(b,b)));
}
//----------------------------------------------GCD-------------------------------------------------
pair<ll,ll> Egcd(ll a,ll b)
{
  if(b==0)
    return make_pair(1,0);
  pair<ll,ll> t=Egcd(b,a%b);
  return make_pair(t.se,t.fi-(a/b)*t.se);
}
//------------------------------------------------------------------------------------------

void solve()
{
  ll n;
  cin>>n;
  ll i;
  vll a(n+1);
  for(i=0;i<n;i++)
    cin>>a[i];
  ll x=0,p=1;
  ll h=1,y=0;
  if(n==1)
  {
    cout<<0<<endl;
    return;
  }
  for(i=1;i<n;i++)
  {
    if(a[i-1]<a[i]){
      x++;
    }

    else
    {
      y++;
      if(y>=p)
      {

        h++;
        p=x;
        x=1;
        y=0;
      }
    }
  }
cout<<h<<endl;
}

int main(){
    FAST;
        #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ll t;
cin>>t;
while(t--)
solve();
}


/*Author-Ayush Tiwari
JAI_SHREE_RAM         */

#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)

using namespace std;
typedef long long int ll;
//-------------------------------------Mod_operations------------------------------------------
const ll M = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;
ll mod(ll x){   return (x%M);}
ll mod_minus(ll a, ll b){ ll ans= (mod(a)-mod(b)); if(ans<0) ans=mod(ans+M); return ans;}
ll mod_mul(ll a,ll b){  return mod(mod(a)*mod(b));}
ll mod_add(ll a,ll b){ return mod(mod(a)+mod(b));}
ll power(ll a,ll n){  if(n==0) return 1;  else if(n==1) return a;  ll R=power(a,n/2);  if(n%2==0) {  return R*R; }   else { return R*a*R;  }}

ll mod_div(ll a,ll b){// only if M is prime
    ll ans=mod(a);
    ll b1=power(b,M-2);
     ans= mod(mod_mul(ans,b1));
     return ans;
}

ll fact_mod(ll n){
    vll fact(n+1);
    fact[0]=1;
    for(ll i=1;i<n+1;i++){
        fact[i]=mod_mul(fact[i-1],i);
    }
    return fact[n];
}
ll nCr_mod(ll n , ll r){
    return mod( mod_mul(mod_mul(fact_mod(n),mod(fact_mod(power(r,M-2))) ),
                                       mod(power(fact_mod(n-r),M-2))   )   );
}
//-----------------------------GEOMETRY-----------------------------------------------
template<typename T>
class Cpoint
{
    public:
        T x,y,z;
    Cpoint(T tmp_x, T tmp_y=0, T tmp_z=0)
    {
        x=tmp_x;
        y=tmp_y;
        z=tmp_z;
    }

    Cpoint operator+(Cpoint b)
    {
        return Cpoint(this->x+b.x, this->y+b.y, this->z+b.z);
    }
    Cpoint operator-(Cpoint b)
    {
        return Cpoint(this->x-b.x, this->y-b.y, this->z-b.z);
    }

    Cpoint& operator+=(Cpoint b)
    {
        *this=*this+b;
        return *this;
    }
};

template<typename T>
T dot(Cpoint<T> a,Cpoint<T> b)
{
    return a.x*b.x+a.y*b.y+a.z*b.z;
}

template<typename T>
float ang(Cpoint<T> a,Cpoint<T> b)
{
    return acos(dot(a,b)/sqrt(dot(a,a)*dot(b,b)));
}
//----------------------------------------------GCD-------------------------------------------------
pair<ll,ll> Egcd(ll a,ll b)
{
  if(b==0)
    return make_pair(1,0);
  pair<ll,ll> t=Egcd(b,a%b);
  return make_pair(t.se,t.fi-(a/b)*t.se);
}
//------------------------------------------------------------------------------------------

void solve()
{
  ll n;
  cin>>n;
  ll i;
  vll a(n+1);
  for(i=0;i<n;i++)
    cin>>a[i];
  ll x=1;
  for(i=1;i<n;i++)
  {
    if(a[i-1]<a[i])
      continue;
    x++;
  }
  cout<<x<<endl;
}
int main(){
    FAST;
        #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ll t;
cin>>t;
while(t--)
solve();
}


/*Author-Ayush Tiwari
JAI_SHREE_RAM         */

#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)

using namespace std;
typedef long long int ll;
//-------------------------------------Mod_operations------------------------------------------
const ll M = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;
ll mod(ll x){   return (x%M);}
ll mod_minus(ll a, ll b){ ll ans= (mod(a)-mod(b)); if(ans<0) ans=mod(ans+M); return ans;}
ll mod_mul(ll a,ll b){  return mod(mod(a)*mod(b));}
ll mod_add(ll a,ll b){ return mod(mod(a)+mod(b));}
ll power(ll a,ll n){  if(n==0) return 1;  else if(n==1) return a;  ll R=power(a,n/2);  if(n%2==0) {  return R*R; }   else { return R*a*R;  }}

ll mod_div(ll a,ll b){// only if M is prime
    ll ans=mod(a);
    ll b1=power(b,M-2);
     ans= mod(mod_mul(ans,b1));
     return ans;
}

ll fact_mod(ll n){
    vll fact(n+1);
    fact[0]=1;
    for(ll i=1;i<n+1;i++){
        fact[i]=mod_mul(fact[i-1],i);
    }
    return fact[n];
}
ll nCr_mod(ll n , ll r){
    return mod( mod_mul(mod_mul(fact_mod(n),mod(fact_mod(power(r,M-2))) ),
                                       mod(power(fact_mod(n-r),M-2))   )   );
}
//-----------------------------GEOMETRY-----------------------------------------------
template<typename T>
class Cpoint
{
    public:
        T x,y,z;
    Cpoint(T tmp_x, T tmp_y=0, T tmp_z=0)
    {
        x=tmp_x;
        y=tmp_y;
        z=tmp_z;
    }

    Cpoint operator+(Cpoint b)
    {
        return Cpoint(this->x+b.x, this->y+b.y, this->z+b.z);
    }
    Cpoint operator-(Cpoint b)
    {
        return Cpoint(this->x-b.x, this->y-b.y, this->z-b.z);
    }

    Cpoint& operator+=(Cpoint b)
    {
        *this=*this+b;
        return *this;
    }
};

template<typename T>
T dot(Cpoint<T> a,Cpoint<T> b)
{
    return a.x*b.x+a.y*b.y+a.z*b.z;
}

template<typename T>
float ang(Cpoint<T> a,Cpoint<T> b)
{
    return acos(dot(a,b)/sqrt(dot(a,a)*dot(b,b)));
}
//----------------------------------------------GCD-------------------------------------------------
pair<ll,ll> Egcd(ll a,ll b)
{
  if(b==0)
    return make_pair(1,0);
  pair<ll,ll> t=Egcd(b,a%b);
  return make_pair(t.se,t.fi-(a/b)*t.se);
}
//------------------------------------------------------------------------------------------

void solve()
{
  ll n;
  cin>>n;
  ll i;
  vll a(n+1);
  for(i=0;i<n;i++)
    cin>>a[i];
  ll x=0,p=1;
  ll h=1,y=0;
  if(n==1)
  {
    cout<<0<<endl;
    return;
  }
  for(i=1;i<n;i++)
  {
    if(a[i-1]<a[i]){
      x++;
    }

    else
    {
      y++;
      if(y>=p)
      {

        h++;
        p=x;
        x=0;
        y=1;
      }
    }
  }
cout<<h<<endl;
}

int main(){
    FAST;
        #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ll t;
cin>>t;
while(t--)
solve();
}


/*Author-Ayush Tiwari
JAI_SHREE_RAM         */

#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)

using namespace std;
typedef long long int ll;
//-------------------------------------Mod_operations------------------------------------------
const ll M = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;
ll mod(ll x){   return (x%M);}
ll mod_minus(ll a, ll b){ ll ans= (mod(a)-mod(b)); if(ans<0) ans=mod(ans+M); return ans;}
ll mod_mul(ll a,ll b){  return mod(mod(a)*mod(b));}
ll mod_add(ll a,ll b){ return mod(mod(a)+mod(b));}
ll power(ll a,ll n){  if(n==0) return 1;  else if(n==1) return a;  ll R=power(a,n/2);  if(n%2==0) {  return R*R; }   else { return R*a*R;  }}

ll mod_div(ll a,ll b){// only if M is prime
    ll ans=mod(a);
    ll b1=power(b,M-2);
     ans= mod(mod_mul(ans,b1));
     return ans;
}

ll fact_mod(ll n){
    vll fact(n+1);
    fact[0]=1;
    for(ll i=1;i<n+1;i++){
        fact[i]=mod_mul(fact[i-1],i);
    }
    return fact[n];
}
ll nCr_mod(ll n , ll r){
    return mod( mod_mul(mod_mul(fact_mod(n),mod(fact_mod(power(r,M-2))) ),
                                       mod(power(fact_mod(n-r),M-2))   )   );
}
//-----------------------------GEOMETRY-----------------------------------------------
template<typename T>
class Cpoint
{
    public:
        T x,y,z;
    Cpoint(T tmp_x, T tmp_y=0, T tmp_z=0)
    {
        x=tmp_x;
        y=tmp_y;
        z=tmp_z;
    }

    Cpoint operator+(Cpoint b)
    {
        return Cpoint(this->x+b.x, this->y+b.y, this->z+b.z);
    }
    Cpoint operator-(Cpoint b)
    {
        return Cpoint(this->x-b.x, this->y-b.y, this->z-b.z);
    }

    Cpoint& operator+=(Cpoint b)
    {
        *this=*this+b;
        return *this;
    }
};

template<typename T>
T dot(Cpoint<T> a,Cpoint<T> b)
{
    return a.x*b.x+a.y*b.y+a.z*b.z;
}

template<typename T>
float ang(Cpoint<T> a,Cpoint<T> b)
{
    return acos(dot(a,b)/sqrt(dot(a,a)*dot(b,b)));
}
//----------------------------------------------GCD-------------------------------------------------
pair<ll,ll> Egcd(ll a,ll b)
{
  if(b==0)
    return make_pair(1,0);
  pair<ll,ll> t=Egcd(b,a%b);
  return make_pair(t.se,t.fi-(a/b)*t.se);
}
//------------------------------------------------------------------------------------------

void solve()
{
  ll n;
  cin>>n;
  ll i;
  vll a(n+1);
  for(i=0;i<n;i++)
    cin>>a[i];
  ll x=0,p=0;
  ll h=1,y=0;
  for(i=1;i<n;i++)
  {
    if(a[i-1]<a[i])
      x++;
    else
    {
      y++;
      if(y+1>p)
      {
        h++;
        p=x;
        x=0;
        y=0;
      }
    }
  }
  cout<<h<<endl;
}
int main(){
    FAST;
        #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ll t;
cin>>t;
while(t--)
solve();
}


/*Author-Ayush Tiwari
JAI_SHREE_RAM         */

#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)

using namespace std;
typedef long long int ll;
//-------------------------------------Mod_operations------------------------------------------
const ll M = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;
ll mod(ll x){   return (x%M);}
ll mod_minus(ll a, ll b){ ll ans= (mod(a)-mod(b)); if(ans<0) ans=mod(ans+M); return ans;}
ll mod_mul(ll a,ll b){  return mod(mod(a)*mod(b));}
ll mod_add(ll a,ll b){ return mod(mod(a)+mod(b));}
ll power(ll a,ll n){  if(n==0) return 1;  else if(n==1) return a;  ll R=power(a,n/2);  if(n%2==0) {  return R*R; }   else { return R*a*R;  }}

ll mod_div(ll a,ll b){// only if M is prime
    ll ans=mod(a);
    ll b1=power(b,M-2);
     ans= mod(mod_mul(ans,b1));
     return ans;
}

ll fact_mod(ll n){
    vll fact(n+1);
    fact[0]=1;
    for(ll i=1;i<n+1;i++){
        fact[i]=mod_mul(fact[i-1],i);
    }
    return fact[n];
}
ll nCr_mod(ll n , ll r){
    return mod( mod_mul(mod_mul(fact_mod(n),mod(fact_mod(power(r,M-2))) ),
                                       mod(power(fact_mod(n-r),M-2))   )   );
}
//-----------------------------GEOMETRY-----------------------------------------------
template<typename T>
class Cpoint
{
    public:
        T x,y,z;
    Cpoint(T tmp_x, T tmp_y=0, T tmp_z=0)
    {
        x=tmp_x;
        y=tmp_y;
        z=tmp_z;
    }

    Cpoint operator+(Cpoint b)
    {
        return Cpoint(this->x+b.x, this->y+b.y, this->z+b.z);
    }
    Cpoint operator-(Cpoint b)
    {
        return Cpoint(this->x-b.x, this->y-b.y, this->z-b.z);
    }

    Cpoint& operator+=(Cpoint b)
    {
        *this=*this+b;
        return *this;
    }
};

template<typename T>
T dot(Cpoint<T> a,Cpoint<T> b)
{
    return a.x*b.x+a.y*b.y+a.z*b.z;
}

template<typename T>
float ang(Cpoint<T> a,Cpoint<T> b)
{
    return acos(dot(a,b)/sqrt(dot(a,a)*dot(b,b)));
}
//----------------------------------------------GCD-------------------------------------------------
pair<ll,ll> Egcd(ll a,ll b)
{
  if(b==0)
    return make_pair(1,0);
  pair<ll,ll> t=Egcd(b,a%b);
  return make_pair(t.se,t.fi-(a/b)*t.se);
}
//------------------------------------------------------------------------------------------

void solve()
{
  ll n;
  cin>>n;
  ll i;
  vll a(n+1);
  for(i=0;i<n;i++)
    cin>>a[i];
  ll x=0,p=0;
  ll h=1,y=0;
  for(i=1;i<n;i++)
  {
    if(a[i-1]<a[i])
      x++;
    else
    {
      y++;
      if(y>p)
      {
        h++;
        p=x;
        x=0;
      }
    }
  }
  cout<<h<<endl;
}
int main(){
    FAST;
        #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ll t;
cin>>t;
while(t--)
solve();
}


/*Author-Ayush Tiwari
JAI_SHREE_RAM         */

#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)

using namespace std;
typedef long long int ll;
//-------------------------------------Mod_operations------------------------------------------
const ll M = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;
ll mod(ll x){   return (x%M);}
ll mod_minus(ll a, ll b){ ll ans= (mod(a)-mod(b)); if(ans<0) ans=mod(ans+M); return ans;}
ll mod_mul(ll a,ll b){  return mod(mod(a)*mod(b));}
ll mod_add(ll a,ll b){ return mod(mod(a)+mod(b));}
ll power(ll a,ll n){  if(n==0) return 1;  else if(n==1) return a;  ll R=power(a,n/2);  if(n%2==0) {  return R*R; }   else { return R*a*R;  }}

ll mod_div(ll a,ll b){// only if M is prime
    ll ans=mod(a);
    ll b1=power(b,M-2);
     ans= mod(mod_mul(ans,b1));
     return ans;
}

ll fact_mod(ll n){
    vll fact(n+1);
    fact[0]=1;
    for(ll i=1;i<n+1;i++){
        fact[i]=mod_mul(fact[i-1],i);
    }
    return fact[n];
}
ll nCr_mod(ll n , ll r){
    return mod( mod_mul(mod_mul(fact_mod(n),mod(fact_mod(power(r,M-2))) ),
                                       mod(power(fact_mod(n-r),M-2))   )   );
}
//-----------------------------GEOMETRY-----------------------------------------------
template<typename T>
class Cpoint
{
    public:
        T x,y,z;
    Cpoint(T tmp_x, T tmp_y=0, T tmp_z=0)
    {
        x=tmp_x;
        y=tmp_y;
        z=tmp_z;
    }

    Cpoint operator+(Cpoint b)
    {
        return Cpoint(this->x+b.x, this->y+b.y, this->z+b.z);
    }
    Cpoint operator-(Cpoint b)
    {
        return Cpoint(this->x-b.x, this->y-b.y, this->z-b.z);
    }

    Cpoint& operator+=(Cpoint b)
    {
        *this=*this+b;
        return *this;
    }
};

template<typename T>
T dot(Cpoint<T> a,Cpoint<T> b)
{
    return a.x*b.x+a.y*b.y+a.z*b.z;
}

template<typename T>
float ang(Cpoint<T> a,Cpoint<T> b)
{
    return acos(dot(a,b)/sqrt(dot(a,a)*dot(b,b)));
}
//----------------------------------------------GCD-------------------------------------------------
pair<ll,ll> Egcd(ll a,ll b)
{
  if(b==0)
    return make_pair(1,0);
  pair<ll,ll> t=Egcd(b,a%b);
  return make_pair(t.se,t.fi-(a/b)*t.se);
}
//------------------------------------------------------------------------------------------

void solve()
{
  ll n;
  cin>>n;
  ll i;
  vll a(n+1);
  for(i=0;i<n;i++)
    cin>>a[i];
  ll x=0,p=1;
  ll h=1,y=0;
  if(n==1)
  {
    cout<<0<<endl;
    return;
  }
   ll fr=0;
        ll nfr=1;
  for(i=2;i<n;i++)
  {
        if(a[i]>a[i-1])
            {
                nfr++;
            }
            else if(fr>0)
            {
                fr--;
                nfr++;
            }
            else
            {
                h++;
                fr=nfr-1;
                nfr=1;
            }
  }
cout<<h<<endl;
}

int main(){
    FAST;
        #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ll t;
cin>>t;
while(t--)
solve();
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second

#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >

#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)

#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(be(a), x) - a.begin())
#define UB(a, x) (upper_bound(be(a), x) - a.begin())
#define S " "
#define N "\n"

#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define sll(a, b) scanf("%lld %lld", &a, &b)

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

void solve() {
    int n;
    cin >> n;
    int arr[n + 10];
    f(i, 0, n) {
        cin >> arr[i];
    }
    vp seg;
    seg.pb({0, 0});
    int st = 1, end = 1, flag = 0;
    for(int i = 1; i < n; i++) {
        flag = 0;
        if(i + 1 < n and arr[i] < arr[i + 1]) {
            end = i + 1;
        } else {
            flag = 1;
            seg.pb({st, end});
            st = end + 1;
            end = st;
        }
    }
    if(flag == 0) {
        seg.pb({end, n - 1});
    }
    int cnt = 0, pos = 1, child = 0, parent = 1;
    n = seg.size();
    while(pos < n) {
        int flag = 0;
        for(int i = pos; i < min(n, pos + parent); i++) {
            child += seg[i].yy - seg[i].xx + 1;
            flag = 1;
        }
        if(flag) cnt++;
        pos += parent;
        parent = child;
    }
    cout << cnt << N;
}

int main() {
    // FILE;
    fast;

    int t; cin >> t; while(t--)
    solve();
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second

#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >

#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)

#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(be(a), x) - a.begin())
#define UB(a, x) (upper_bound(be(a), x) - a.begin())
#define S " "
#define N "\n"

#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define sll(a, b) scanf("%lld %lld", &a, &b)

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

void solve() {
    int n;
    cin >> n;
    int arr[n + 10];
    f(i, 0, n) {
        cin >> arr[i];
    }
    vp seg;
    seg.pb({0, 0});
    int st = 1, end = 1, flag = 0;
    for(int i = 1; i < n; i++) {
        flag = 0;
        if(i + 1 < n and arr[i] < arr[i + 1]) {
            end = i + 1;
        } else {
            flag = 1;
            seg.pb({st, end});
            st = end + 1;
            end = st;
        }
    }
    if(flag == 0) {
        seg.pb({end, n - 1});
    }
    int cnt = 0, pos = 1, child = 0, parent = 1;
    n = seg.size();
    while(pos < n) {
        int flag = 0;
        for(int i = pos; i < min(n, pos + parent); i++) {
            child += seg[i].yy - seg[i].xx + 1;
            flag = 1;
        }
        if(flag) cnt++;
        parent = child;
        if(pos < n - 1 and pos + parent >= n ) cnt++;
        pos += parent;
        child = 0;
    }
    cout << cnt << N;
}

int main() {
    // FILE;
    fast;

    int t; cin >> t; while(t--)
    solve();
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second

#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >

#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)

#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(be(a), x) - a.begin())
#define UB(a, x) (upper_bound(be(a), x) - a.begin())
#define S " "
#define N "\n"

#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define sll(a, b) scanf("%lld %lld", &a, &b)

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

void solve() {
    int n;
    cin >> n;
    int arr[n + 10];
    f(i, 0, n) {
        cin >> arr[i];
    }
    vp seg;
    seg.pb({0, 0});
    int st = 1, end = 1, flag = 0;
    for(int i = 1; i < n; i++) {
        flag = 0;
        if(i + 1 < n and arr[i] < arr[i + 1]) {
            end = i + 1;
        } else {
            flag = 1;
            seg.pb({st, end});
            st = end + 1;
            end = st;
        }
    }
    if(flag == 0) {
        seg.pb({end, n - 1});
    }
    int cnt = 0, pos = 1, child = 0, parent = 1;
    n = seg.size();
    while(pos < n) {
        int flag = 0;
        for(int i = pos; i < min(n, pos + parent); i++) {
            child += seg[i].yy - seg[i].xx + 1;
            flag = 1;
        }
        if(flag) cnt++;
        parent = child;
        pos += parent;
        child = 0;
    }
    cout << cnt << N;
}

int main() {
    // FILE;
    fast;

    int t; cin >> t; while(t--)
    solve();
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second

#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >

#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)

#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(be(a), x) - a.begin())
#define UB(a, x) (upper_bound(be(a), x) - a.begin())
#define S " "
#define N "\n"

#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define sll(a, b) scanf("%lld %lld", &a, &b)

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

void solve() {
    int n;
    cin >> n;
    int arr[n + 10];
    f(i, 0, n) {
        cin >> arr[i];
    }
    vp seg;
    seg.pb({0, 0});
    int st = 1, end = 1, flag = 0;
    for(int i = 1; i < n; i++) {
        flag = 0;
        if(i + 1 < n and arr[i] < arr[i + 1]) {
            end = i + 1;
        } else {
            flag = 1;
            seg.pb({st, end});
            st = end + 1;
            end = st;
        }
    }
    if(flag == 0) {
        seg.pb({end, n - 1});
    }
    int cnt = 0, pos = 1, child = 0, parent = 1;
    n = seg.size();
    while(pos < n) {
        int flag = 0, temp = 0;
        for(int i = pos; i < min(n, pos + parent); i++) {
            child += seg[i].yy - seg[i].xx + 1;
            flag = 1;
            temp++;
        }
        pos = pos + temp;
        if(flag) cnt++;
        parent = child;
        // if(pos < n - 1 and pos + parent >= n ) cnt++;
        // pos += parent;
        child = 0;
    }
    cout << cnt << N;
}

int main() {
    // FILE;
    fast;

    int t; cin >> t; while(t--)
    solve();
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second

#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >

#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)

#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(be(a), x) - a.begin())
#define UB(a, x) (upper_bound(be(a), x) - a.begin())
#define S " "
#define N "\n"

#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define sll(a, b) scanf("%lld %lld", &a, &b)

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

void solve() {
    int n;
    cin >> n;
    vi v(n);
    f(i, 0, n) {
        cin >> v[i];
    }
    reverse(be(v));
    int root = v.back();
    v.pop_back();
    int depth[n + 10], par[n + 10];
    mem(depth), mem(par);
    depth[root] = par[root] = 0;
    queue < int > q;
    q.push(root);
    int ans = 0;
    while(!q.empty()) {
        int u = q.front();
        ans = max(ans, depth[u]);
        q.pop();
        int last = 0;
        while(v.size() and v.back() > last) {
            int x = v.back();
            v.pop_back();
            par[x] = u;
            depth[x] = depth[u] + 1;
            q.push(x);
            last = x;
        }
    }
    cout << ans << N;
}

int main() {
    // FILE;
    fast;

    int t; cin >> t; while(t--)
    solve();
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second

#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >

#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)

#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(be(a), x) - a.begin())
#define UB(a, x) (upper_bound(be(a), x) - a.begin())
#define S " "
#define N "\n"

#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define sll(a, b) scanf("%lld %lld", &a, &b)

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

void solve() {
    int n;
    cin >> n;
    int arr[n + 10];
    f(i, 0, n) {
        cin >> arr[i];
    }
    vp seg;
    seg.pb({0, 0});
    int st = 1, end = 1, flag = 0;
    for(int i = 1; i < n; i++) {
        flag = 0;
        if(i + 1 < n and arr[i] < arr[i + 1]) {
            end = i + 1;
        } else {
            flag = 1;
            seg.pb({st, end});
            st = end + 1;
            end = st;
        }
    }
    if(flag == 0) {
        seg.pb({end, n - 1});
    }
    int cnt = 0, pos = 1, child = 0, parent = 1;
    n = seg.size();
    while(pos < n) {
        int flag = 0, temp = 0;
        for(int i = pos; i < min(n, pos + parent); i++) {
            child += seg[i].yy - seg[i].xx + 1;
            flag = 1;
            temp++;
        }
        pos = pos + temp;
        if(flag) cnt++;
        parent = child;
        if(pos < n - 1 and pos + parent >= n ) cnt++;
        // pos += parent;
        child = 0;
    }
    cout << cnt << N;
}

int main() {
    // FILE;
    fast;

    int t; cin >> t; while(t--)
    solve();
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];
int lv[200001];
vector<vector<int>>adj;
void init_tr(int u, int p) {
	for (int v : adj[u]) {
		if (v == p) continue;
		lv[v] = lv[u] + 1;
		init_tr(v, u);
	}
	return;
}

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		queue<int> q;
		int cnt = 0;
		int ans = 1;
		int k = 1;
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if (A[i] < A[i - 1]) {
					q.push(cnt);
					if (k == 1) {
						k = q.front();
						q.pop();
						ans++;
					}
					cnt = 1;
				}
				else {
					cnt++;
				}
			}
		}
		cout << ans << '\n';

		/*int cnt = 0;
		int root = 0;
		int now = 1;
		int idx = 0;
		ans = 0;
		adj.assign(n + 1, vector<int>());
		adj[0].push_back(1);
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if(i == 2 || A[i] < A[i-1]) {
					if (root == 0 || idx == adj[root].size() - 1) {
						root = adj[root][0];
						now = root;
						adj[now].push_back(A[i]);
						idx = 0;
					}
					else {
						now = adj[root][idx + 1];
						idx++;
						adj[now].push_back(A[i]);
					}
				}
				else {
					 adj[now].push_back(A[i]);
				}
			}
		}
		init_tr(1, 1);*/
		//cout << ans << '\n';

	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];
int lv[200001];
int ans;
vector<vector<int>>adj;
void init_tr(int u, int p) {
	for (int v : adj[u]) {
		if (v == p) continue;
		lv[v] = lv[u] + 1;
		ans = max(ans, lv[v]);
		init_tr(v, u);
	}
	return;
}

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		int cnt = 0;
		int root = 1;
		int now = 1;
		int idx = 0;
		ans = 0;
		adj.assign(n + 1, vector<int>());
		adj[0].push_back(1);
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if (A[i] > A[i - 1]) adj[now].push_back(A[i]);
				else {
					if (root == 1 || idx == adj[root].size() - 1) {
						root = adj[root][0];
						now = root;
						adj[now].push_back(A[i]);
						idx = 0;
					}
					else {
						now = adj[root][idx + 1];
						idx++;
						adj[now].push_back(A[i]);
					}
				}
			}
		}
		init_tr(1, 1);
		cout << ans << '\n';

	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		queue<int> q;
		int cnt = 0;
		int ans = 1;
		int k = 1;
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if (A[i] < A[i - 1]) {
					q.push(cnt);
					if (k == 1) {
						k = q.front();
						q.pop();
						ans++;
						cnt = 1;
					}
					else {
						k--;
					}
					cnt = 0;
				}
				else {
					cnt++;
				}
			}
		}
		cout << ans << '\n';
	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		memset(A, 0, sizeof(A));
		int ans = 0;
		int k = 1;
		int cnt = 1;
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if (i == 2 || A[i] < A[i - 1]) {
					k--;
					if (k == 0) {
						k = cnt;
						cnt = 1;
						ans++;
					}
				}
				else cnt++;
			}
		}
		cout << ans << '\n';
	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];
int lv[200001];
int ans;
vector<vector<int>>adj;
void init_tr(int u, int p) {
	for (int v : adj[u]) {
		if (v == p) continue;
		lv[v] = lv[u] + 1;
		ans = max(ans, lv[v]);
		init_tr(v, u);
	}
	return;
}

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		int cnt = 0;
		int root = 0;
		int now = 1;
		int idx = 0;
		ans = 0;
		adj.assign(n + 1, vector<int>());
		adj[0].push_back(1);
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if(i == 2 || A[i] < A[i-1]) {
					if (root == 0 || idx == adj[root].size() - 1) {
						root = adj[root][0];
						now = root;
						adj[now].push_back(A[i]);
						idx = 0;
					}
					else {
						now = adj[root][idx + 1];
						idx++;
						adj[now].push_back(A[i]);
					}
				}
				else {
					 adj[now].push_back(A[i]);
				}
			}
		}
		init_tr(1, 1);
		cout << ans << '\n';

	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];
int lv[200001];
vector<vector<int>>adj;

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		queue<int> q;
		int cnt = 0;
		int ans = 1;
		int k = 1;
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if (A[i] < A[i - 1]) {
					q.push(cnt);
					if (k == 1) {
						k = q.front();
						q.pop();
						ans++;
					}
					else {
						k--;
					}
					cnt = 1;
				}
				else {
					cnt++;
				}
			}
		}
		cout << ans << '\n';
	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		int ans = 0;
		int k = 1;
		int cnt = 1;
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			A[1] = MAX;
			if (i >= 2) {
				if (A[i] < A[i - 1]) {
					k--;
					if (k == 0) {
						k = cnt;
						cnt = 0;
						ans++;
					}
					cnt++;
				}
				else cnt++;
			}
		}
		cout << ans << '\n';
	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		memset(A, 0, sizeof(A));
		int ans = 0;
		int k = 1;
		int cnt = 1;
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			A[1] = MAX;
			if (i >= 2) {
				if (A[i] < A[i - 1]) {
					k--;
					if (k == 0) {
						k = cnt;
						cnt = 1;
						ans++;
					}
				}
				else cnt++;
			}
		}
		cout << ans << '\n';
	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		memset(A, 0, sizeof(A));
		queue<int> q;
		int ans = 1;
		int k = 1;
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if (A[i] < A[i - 1]) {
					k--;
					if (k == 0) {
						k = cnt;
						cnt = 1;
						ans++;
					}
				}
				else cnt++;
			}
		}
		cout << ans << '\n';
	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];
int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if (A[i] < A[i - 1]) cnt++;
			}
		}
		cout << cnt+1 << '\n';
	}
}


#include<bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);
int A[200001];

int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		memset(A, 0, sizeof(A));
		queue<int> q;
		int cnt = 0;
		int ans = 1;
		int k = 1;
		for (int i = 1; i <= n; i++) {
			cin >> A[i];
			if (i >= 2) {
				if (A[i] < A[i - 1]) {
					q.push(cnt);
					if (k == 1) {
						k = q.front();
						q.pop();
						ans++;
					}
					else {
						k--;
					}
					cnt = 1;
				}
				else {
					cnt++;
				}
			}
		}
		cout << ans << '\n';
	}
}


/*
   Username : moondancer
   Name : Moon Dancer
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        int a[n+1];
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
        }
        int ans = 0;
        stack<int> s;
        // s.push(1);
        for (int i = 2; i <= n; ++i) {
            while(!s.empty() && a[i] > s.top()) {
                s.pop();
            }
            s.push(a[i]);
            ans = max(ans, (int)s.size());
        }
        cout<<ans<<"\n";
    }
    return 0;
}


/*
   Username : moondancer
   Name : Moon Dancer
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        int a[n+1];
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
        }
        int ans = 0;
        stack<int> s;
        // s.push(1);
        for (int i = 2; i <= n; ++i) {
            if(s.empty()) {
                s.push(a[i]);
            }
            else {
                if(a[i] < s.top()) {
                    s.push(a[i]);
                }
                else {
                    s.pop();
                    s.push(a[i]);
                }
            }
            ans = max(ans, (int)s.size());
        }
        cout<<ans<<"\n";
    }
    return 0;
}


/*
   Username : moondancer
   Name : Moon Dancer
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        int a[n+1];
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
        }
        int ans = 0;
        stack<int> s;
        s.push(1);
        for (int i = 2; i <= n; ++i) {
            if(s.empty()) {
                s.push(a[i]);
            }
            else {
                while(!s.empty() && a[i] > s.top()) {
                    s.pop();
                }
                s.push(a[i]);
            }
            ans = max(ans, (int)s.size());
        }
        cout<<ans<<"\n";
    }
    return 0;
}


/*
   Username : moondancer
   Name : Moon Dancer
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        int a[n+1];
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
        }
        int ans = 0;
        stack<int> s;
        // s.push(1);
        for (int i = 2; i <= n; ++i) {
            if(s.empty()) {
                s.push(a[i]);
            }
            else {
                while(!s.empty() && a[i] > s.top()) {
                    s.pop();
                }
                s.push(a[i]);
            }
            ans = max(ans, (int)s.size());
        }
        cout<<ans<<"\n";
    }
    return 0;
}


/*
   Username : moondancer
   Name : Moon Dancer
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        int a[n] = {};
        for (int i = 0; i < n; ++i) {
            cin>>a[i];
        }
        int ans = 1;
        int x=0, y=0;
        for (int i = 1; i < n; ++i) {
            if(a[i-1] < a[i]) {
                x++;
            }
            else {
                if(!y) {
                    ans++;
                    y=x-1;
                }
                else {
                    y--;
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


/*
   Username : moondancer
   Name : Moon Dancer
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

int lis(vector<int> const& a) {
    int n = a.size();
    const int INF = 1e9;
    vector<int> d(n+1, INF);
    d[0] = -INF;

    for (int i = 0; i < n; i++) {
        int j = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
        if (d[j-1] < a[i] && a[i] < d[j])
            d[j] = a[i];
    }

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if (d[i] < INF)
            ans = i;
    }
    return ans;
}

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        // int a[n+1];
        vector<int> v;
        for (int i = 1; i <= n; ++i) {
            // cin >> a[i];
            int x;
            cin>>x;
            v.push_back(x);
        }
        reverse(v.begin(), v.end());
        v.pop_back();
        cout << lis(v) <<"\n";
        // int ans = 0;
        // stack<int> s;
        // // s.push(1);
        // for (int i = 2; i <= n; ++i) {
        //     if(s.empty()) {
        //         s.push(a[i]);
        //     }
        //     else {
        //         while(!s.empty() && a[i] > s.top()) {
        //             s.pop();
        //         }
        //         s.push(a[i]);
        //     }
        //     ans = max(ans, (int)s.size());
        // }
        // cout<<ans<<"\n";
    }
    return 0;
}


/*
   Username : moondancer
   Name : Moon Dancer
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        int a[n];
        for (int i = 0; i < n; ++i) {
            cin>>a[i];
        }
        int ans = 0;
        deque<pair<int,int>> q;
        q.push_back({n+1,0});
        for (int i = 1; i < n; ++i) {
            // if(q.empty()) {
            //     q.push_back(a[i]);
            // }
            // else {
                if(q.back().first < a[i]) {
                    q.push_back({a[i],q.back().second});
                }
                else {
                    int x = q.front().second;
                    q.pop_front();
                    q.push_back({a[i],x+1});
                }
            // }
        }
        cout<<q.back().second<<"\n";
        // cout<<ans<<"\n";
    }
    return 0;
}


/*
   Username : moondancer
   Name : Moon Dancer
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        int a[n+1];
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
        }
        int ans = 1;
        int cur = 1;
        for (int i = 3; i <= n; ++i) {
            if(a[i-1] > a[i]) {
                cur++;
            }
            else {
                cur = 1;
            }
            ans = max(ans, cur);
        }
        cout<<ans<<"\n";
    }
    return 0;
}


/*
   Username : moondancer
   Name : Moon Dancer
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        int a[n];
        for (int i = 0; i < n; ++i) {
            cin>>a[i];
        }
        int ans = 1;
        for (int i = 1; i < n; ++i) {
            if(a[i-1] > a[i])
                ans++;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n+5];
        for(int i=0;i<n;i++) cin>>a[i];
        int ans=1;
        queue<pair<int,int>> q;
        int l=1;
        for(int i=1;i<n;i++)
        {
            if(i==1) q.push({a[i],1});
            else
            {
                int level=q.front().second;
                if(a[i]>a[i-1]) q.push({a[i],level});
                else
                {
                    q.pop();
                    q.push({a[i],level+1});
                }

            }
        }
        while(q.size()>1) q.pop();
        cout<<q.front().second<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n+5];
        for(int i=0;i<n;i++) cin>>a[i];
        int ans=1;
        queue<pair<int,int>> q;
        int l=1;
        for(int i=1;i<n;i++)
        {
            if(i==1) q.push({a[i],1});
            else if(a[i]>q.front().first) q.push({a[i],q.front().second});
            else if(a[i]<q.front().first)
            {
                q.push({a[i],1+q.front().second});
                q.pop();
                //cout<<q.front().first<<" "<<q.front().second<<endl;
            }
        }
        while(q.size()>1) q.pop();
        cout<<q.front().second<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n+5];
        for(int i=0;i<n;i++) cin>>a[i];
        int ans=1;
        queue<pair<int,int>> q;
        int l=1;
        for(int i=1;i<n;i++)
        {
            if(i==1) q.push({a[i],1});
            else
            {
                int level=q.front().second;
                if(a[i]>a[i-1]) q.push({a[i],level});
                else
                {
                    q.pop();
                    q.push({a[i],level+1});
                    ans=max(ans,level+1);
                }

            }
        }
        while(q.size()>1) q.pop();
        cout<<ans<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n+5];
        for(int i=0;i<n;i++) cin>>a[i];
        int ans=1;
        queue<pair<int,int>> q;
        int l=1;
        for(int i=1;i<n;i++)
        {
            if(i==1) q.push({a[i],1});
            else if(a[i]>q.front().first) q.push({a[i],q.front().second});
            else if(a[i]<q.front().first)
            {
                int l=q.front().second;
                q.pop();
                q.push({a[i],1+l});
                //cout<<q.front().first<<" "<<q.front().second<<endl;
            }
        }
        while(q.size()>1) q.pop();
        cout<<q.front().second<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n+5];
        for(int i=0;i<n;i++) cin>>a[i];
        int ans=1;
        queue<pair<int,int>> q;
        int l=1;
        for(int i=1;i<n;i++)
        {
            if(i==1) q.push({a[i],1});
            else if(a[i]>a[i-1]) q.push({a[i],q.front().second});
            else
            {
                int l=q.front().second;
                q.pop();
                q.push({a[i],1+l});
                //cout<<q.front().first<<" "<<q.front().second<<endl;
            }
        }
        while(q.size()>1) q.pop();
        cout<<q.front().second<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n+5];
        for(int i=0;i<n;i++) cin>>a[i];
        int ans=1;
        if(n>2)
        {
            for(int i=1;i<n;i++)
            {
                if(a[i-1]>a[i]) ans++;
            }
        }
        cout<<ans<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

vi a;

void printNGE(vector < int > arr, int n) {
  stack < int > s;

  /* push the first element to stack */
  s.push(arr[0]);

  // iterate for rest of the elements
  for (int i = 1; i < n; i++) {

    if (s.empty()) {
      s.push(arr[i]);
      continue;
    }

    /* if stack is not empty, then
       pop an element from stack.
       If the popped element is smaller
       than next, then
    a) print the pair
    b) keep popping while elements are
    smaller and stack is not empty */
    while (s.empty() == false && s.top() < arr[i])
    {
    	a[s.top()] = arr[i];
     // 	db(s.top(), arr[i]);
    //      cout << s.top() << " --> " << arr[i] << endl;
        s.pop();
    }

    /* push next to stack so that we can find
    next greater for it */
    s.push(arr[i]);
  }

  /* After iterating over the loop, the remaining
  elements in stack do not have the next greater
  element, so print -1 for them */
  while (s.empty() == false) {
  	a[s.top()] =  - 1;
   //   cout << s.top() << " --> " << -1 << endl;
    s.pop();
  }
}

int32_t main()
{
	fastIO
	inp_out();
	int t;
	cin >> t;
	while(t-- )
	{
		int n;
		cin >> n;
		a = vi(n + 1);
		vector < int > vis(n + 1);
		vi v(n);
		for(int i = 0; i < n; ++ i)
		{
			cin >> v[i];
		}

		printNGE(v, n);

		int ans = 0;

		vis[1] = 1;
		int cnt = 1, x = 0, sz = 0;

		int leaves = 0;

		vi temp;
		for(int i = 1; i < n; ++ i)
		{
		 	if(vis[v[i]] == 0)
			{
				sz = 1;
				int val = v[i];
				vis[val] = 1;

				while(a[val] !=  - 1 && vis[a[val]] == 0)
				{
					++ sz;
					val = a[val];
					vis[val] = 1;
				}
				temp.pb(sz);
			}
		}

		a = temp;
		n = a.size();

		int cur = 1;
		cnt = 0;
		int store = 0;

		int i = 0;
		for(int i = 0; i < n; ++ i)
		{
			store += a[i];
			++ cnt;
			if(cnt == cur)
			{
				cur = store;
				++ ans;
				store = a[i];
				cnt = 0;
			}
		}

		if(cnt != 0)
			++ ans;

		cout << ans << '\n';

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();
	int t = 1;
	cin >> t;
	while(t-- )
	{
		int n;
		cin >> n;
		vi a(n);
		for(int i = 0; i < n; ++ i)
			cin >> a[i];

		if(n == 3)
			cout << 1 << '\n';
		else cout << (n - 1) << '\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();
	int t = 1;
	cin >> t;
	while(t-- )
	{
		int n;
		cin >> n;
		vi a(n);
		multiset < int > st;
		for(int i = 0; i < n; ++ i)
		{
			cin >> a[i];
			st.insert(a[i]);
		 // 	st.insert(i);
		}

		int ans = 0, diff = 0;
		set < int > done;
		set < int > use;
		while(!st.empty())
		{
		 // 	db(st.size());
			multiset < int > er;
			for(auto i : st)
			{
				if(i - diff > 0)
				{
					if(done.find(i - diff) == done.end())
					{
						use.insert(i - diff);
						er.insert(i);
						done.insert(i - diff);
					}
				}
			}

			for(auto i : er)
				st.erase(st.find(i));

			er.clear();
			for(auto i : st)
			{
				if(one.find(i + diff) == done.end())
				{
					use.insert(i + diff);
					er.insert(i);
					done.insert(i + diff);
				}
			}

			for(auto i : er)
				st.erase(st.find(i));
			 ++ diff;
		}

	 // 	db(use.size());

		sort(a.begin(), a.end());
		int idx =  - 1;
		for(auto i : use)
		{
		 // 	db(i);
			++ idx;
			ans += abs(a[idx] - i);
		}

		cout << ans << '\n';

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();
	int t;
	cin >> t;
	while(t-- )
	{
		int n;
		cin >> n;
		vi a(n);
		for(int i = 0; i < n; ++ i)
			cin >> a[i];

		vi depth(n + 1);
		depth[0] = 1;

		int i = 1, cur = 0;
		while(i < n)
		{
			int k = 0;
			++ cur;
			while(k < depth[cur - 1] && i < n)
			{
				int val = 0;
				while(a[i] > val && i < n)
				{
					depth[cur]++ ;
					val = a[i];
					++ i;
				}
				++ k;
			}

		}

		cout << cur << '\n';

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

vector < vi > dp;

int cal(int idx, int val, vi &a)
{

 	if(idx < 0)
		return 0;

	if(val <= 0)
		return inf;

	if(dp[idx][val] !=  - 1)
		return dp[idx][val];

	return dp[idx][val] = min(cal(idx, val - 1, a), cal(idx - 1, val - 1, a) + abs(a[idx] - val));

}

int32_t main()
{
	fastIO
	inp_out();
	int t;
	cin >> t;
	while(t-- )
	{
		int n;
		cin >> n;
		vi a(n);
		dp = vector < vi > (n, vi(301,  - 1));
		for(int i = 0; i < n; ++ i)
			cin >> a[i];
		sort(a.begin(), a.end());
		cout << cal(n - 1, 300, a) << '\n';
	}
	return 0;
}