#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ri register int
#define rll register long long
#define fp(i,a,b) for(int i=a;i<=b;++i)
#define IOS std::ios::sync_with_stdio(false)
#define L(a) a<<1
#define R(a) a<<1|1
#define P pair<int,int>
#define pii pair<ll,ll>
#define re(x) read(x)
#define lowbit(x) ((x)&-(x))
#define all(x) (x).begin(),(x).end()
#define Pi 3.1415926
#define rg register
#define gcd(x,y) __gcd(x,y)
#define unq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define mem(x,k) memset(x,k,sizeof x)

// #define TIME

template<typename T>
inline void read(T& t) {
    t = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }while (isdigit(ch)) { t = t * 10 + ch - '0'; ch = getchar(); }t *= f;
}

void TEST() { cout << "OK!!!" << endl; }
const int dx[4] = { 1,-1,1,-1 };
const int dy[4] = { -1,1,1,-1 };
// const int ddx[4]={0,1,0,-1};
// const int ddy[4]={1,0,-1,0k;
// const int dx[8]={0,-1,0,1,-1,1,1,-1};
// const int dy[8]={-1,0,1,0,1,-1,1,-1};
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
//const ll inf=9e18;

const double eps = 1e-5;
const int maxn = 2e5+10;

int w[maxn];

queue<int> q;

int main() {

    // freopen("1.in", "r", stdin);
    // freopen("ans.out", "w", stdout);

#ifdef TIME
    clock_t start = clock();
#endif
//------------------------------------------------------------------------------------------------
    int t;
    re(t);
    while (t--) {
        int n;
        re(n);
        fp(i, 1, n) {
            re(w[i]);
        }
        int ans=1;
        int pre=w[2];
        q.push(w[2]);
        fp(i,3,n){
            if(w[i]>q.back()){
                q.push(w[i]);
            }
            else{
                while(q.size())q.pop();
                ans++;
                q.push(w[i]);
            }
        }
        while(q.size()) q.pop();
        cout<<ans<<endl;
    }

//-----------------------------------------------------------------------------------------------
#ifdef TIME
    clock_t end = clock();
    cout << "Runing Time: " << (double)(end - start) / CLOCKS_PER_SEC * 1000 << "ms" << endl;
#endif
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ri register int
#define rll register long long
#define fp(i,a,b) for(int i=a;i<=b;++i)
#define IOS std::ios::sync_with_stdio(false)
#define L(a) a<<1
#define R(a) a<<1|1
#define P pair<int,int>
#define pii pair<ll,ll>
#define re(x) read(x)
#define lowbit(x) ((x)&-(x))
#define all(x) (x).begin(),(x).end()
#define Pi 3.1415926
#define rg register
#define gcd(x,y) __gcd(x,y)
#define unq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define mem(x,k) memset(x,k,sizeof x)

// #define TIME

template<typename T>
inline void read(T& t) {
    t = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }while (isdigit(ch)) { t = t * 10 + ch - '0'; ch = getchar(); }t *= f;
}

void TEST() { cout << "OK!!!" << endl; }
const int dx[4] = { 1,-1,1,-1 };
const int dy[4] = { -1,1,1,-1 };
// const int ddx[4]={0,1,0,-1};
// const int ddy[4]={1,0,-1,0k;
// const int dx[8]={0,-1,0,1,-1,1,1,-1};
// const int dy[8]={-1,0,1,0,1,-1,1,-1};
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
//const ll inf=9e18;

const double eps = 1e-5;
const int maxn = 2e5+10;

int w[maxn];

queue<int> q;

int main() {

    // freopen("1.in", "r", stdin);
    // freopen("ans.out", "w", stdout);

#ifdef TIME
    clock_t start = clock();
#endif
//------------------------------------------------------------------------------------------------
    int t;
    re(t);
    while (t--) {
        int n;
        re(n);
        fp(i, 1, n) {
            re(w[i]);
        }
        w[n+1]=-1;
        int ans=0;
        int cnt=0;
        int pre=1;
        int prenode=1;
        int now=0;
        fp(i,2,n+1){
            if(w[i]>pre){
                now++;
            }
            else{
                cnt++;
                if(cnt==prenode){
                    ans++;
                    cnt=0;
                    prenode=now;
                    now=1;
                }
                else now++;
            }
            pre=w[i];
        }
        if(cnt!=0) ans++;
        cout<<ans<<endl;
    }

//-----------------------------------------------------------------------------------------------
#ifdef TIME
    clock_t end = clock();
    cout << "Runing Time: " << (double)(end - start) / CLOCKS_PER_SEC * 1000 << "ms" << endl;
#endif
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ri register int
#define rll register long long
#define fp(i,a,b) for(int i=a;i<=b;++i)
#define IOS std::ios::sync_with_stdio(false)
#define L(a) a<<1
#define R(a) a<<1|1
#define P pair<int,int>
#define pii pair<ll,ll>
#define re(x) read(x)
#define lowbit(x) ((x)&-(x))
#define all(x) (x).begin(),(x).end()
#define Pi 3.1415926
#define rg register
#define gcd(x,y) __gcd(x,y)
#define unq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define mem(x,k) memset(x,k,sizeof x)

// #define TIME

template<typename T>
inline void read(T& t) {
    t = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }while (isdigit(ch)) { t = t * 10 + ch - '0'; ch = getchar(); }t *= f;
}

void TEST() { cout << "OK!!!" << endl; }
const int dx[4] = { 1,-1,1,-1 };
const int dy[4] = { -1,1,1,-1 };
// const int ddx[4]={0,1,0,-1};
// const int ddy[4]={1,0,-1,0k;
// const int dx[8]={0,-1,0,1,-1,1,1,-1};
// const int dy[8]={-1,0,1,0,1,-1,1,-1};
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
//const ll inf=9e18;

const double eps = 1e-5;
const int maxn = 2e5+10;

int w[maxn];

int main() {

    // freopen("1.in", "r", stdin);
    // freopen("ans.out", "w", stdout);

#ifdef TIME
    clock_t start = clock();
#endif
//------------------------------------------------------------------------------------------------
    int t;
    re(t);
    while (t--) {
        int n;
        re(n);
        fp(i, 1, n) {
            re(w[i]);
        }
        int ans=0;
        int pre=1;
        fp(i,2,n){
            if(w[i]==pre+1){
                if(i==n) ans++;
                pre=w[i];
                continue;
            }
            else{
                ans++;
                pre=w[i];
            }
        }
        cout<<ans<<endl;
    }

//-----------------------------------------------------------------------------------------------
#ifdef TIME
    clock_t end = clock();
    cout << "Runing Time: " << (double)(end - start) / CLOCKS_PER_SEC * 1000 << "ms" << endl;
#endif
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ri register int
#define rll register long long
#define fp(i,a,b) for(int i=a;i<=b;++i)
#define IOS std::ios::sync_with_stdio(false)
#define L(a) a<<1
#define R(a) a<<1|1
#define P pair<int,int>
#define pii pair<ll,ll>
#define re(x) read(x)
#define lowbit(x) ((x)&-(x))
#define all(x) (x).begin(),(x).end()
#define Pi 3.1415926
#define rg register
#define gcd(x,y) __gcd(x,y)
#define unq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define mem(x,k) memset(x,k,sizeof x)

// #define TIME

template<typename T>
inline void read(T& t) {
    t = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }while (isdigit(ch)) { t = t * 10 + ch - '0'; ch = getchar(); }t *= f;
}

void TEST() { cout << "OK!!!" << endl; }
const int dx[4] = { 1,-1,1,-1 };
const int dy[4] = { -1,1,1,-1 };
// const int ddx[4]={0,1,0,-1};
// const int ddy[4]={1,0,-1,0k;
// const int dx[8]={0,-1,0,1,-1,1,1,-1};
// const int dy[8]={-1,0,1,0,1,-1,1,-1};
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
//const ll inf=9e18;

const double eps = 1e-5;
const int maxn = 2e5+10;

int w[maxn];

queue<int> q;

int main() {

    // freopen("1.in", "r", stdin);
    // freopen("ans.out", "w", stdout);

#ifdef TIME
    clock_t start = clock();
#endif
//------------------------------------------------------------------------------------------------
    int t;
    re(t);
    while (t--) {
        int n;
        re(n);
        fp(i, 1, n) {
            re(w[i]);
        }
        w[n+1]=-1;
        int ans=0;
        int cnt=0;
        int pre=1;
        int prenode=1;
        int now=0;
        fp(i,2,n+1){
            if(w[i]>pre){
                pre=w[i];
                now++;
            }
            else{
                cnt++;
                if(cnt==prenode){
                    ans++;
                    cnt=0;
                    prenode=now;
                    now=1;
                }
                else now++;
            }
        }
        cout<<ans<<endl;
    }

//-----------------------------------------------------------------------------------------------
#ifdef TIME
    clock_t end = clock();
    cout << "Runing Time: " << (double)(end - start) / CLOCKS_PER_SEC * 1000 << "ms" << endl;
#endif
    return 0;
}


#include <bits/stdc++.h>
#define debug freopen("r.txt","r",stdin)
#define mp make_pair
#define ri register int
#define pb push_back
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> pii;
const int maxn = 1e3+10;
const ll INF = 1e18;
const int mod = 1e9+7;
const double eps=1e-6;
const double PI=acos(-1.0);
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;}
ll qpow(ll p,ll q){return (q&1?p:1)*(q?qpow(p*p%mod,q/2):1)%mod;}
int t,n,a[maxn],i,ans;
int main()
{
	t=read();
	while (t--)
	{
		n=read();
		for (i=1;i<=n;i++) a[i]=read();
		ans=0;
		for (i=1;i<n;i++)
			if (a[i]>a[i+1]) ans++;
		cout<<ans+1<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define debug freopen("r.txt","r",stdin)
#define mp make_pair
#define ri register int
#define pb push_back
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> pii;
const int maxn = 1e3+10;
const ll INF = 1e18;
const int mod = 1e9+7;
const double eps=1e-6;
const double PI=acos(-1.0);
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;}
ll qpow(ll p,ll q){return (q&1?p:1)*(q?qpow(p*p%mod,q/2):1)%mod;}
int t,n,a[maxn],i,ans,num;
int main()
{
	t=read();
	while (t--)
	{
		n=read();
		for (i=1;i<=n;i++) a[i]=read();
		ans=0;num=0;
		for (i=2;i<=n;i++)
			if (a[i]>a[i-1]) num++;
				else break;
		for (;i<=n;i++)
		{
			if (a[i]<a[i-1])
			{
				if (num>1) num--;
					else ans++;
			}
			else
			{
				num++;
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define debug freopen("r.txt","r",stdin)
#define mp make_pair
#define ri register int
#define pb push_back
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> pii;
const int maxn = 1e6+10;
const ll INF = 1e18;
const int mod = 1e9+7;
const double eps=1e-6;
const double PI=acos(-1.0);
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;}
ll qpow(ll p,ll q){return (q&1?p:1)*(q?qpow(p*p%mod,q/2):1)%mod;}
int t,n,a[maxn],i,ans,num,len,d[maxn],vis[maxn];
bool cmp(int x,int y)
{
	return x > y;
}
int main()
{
	t=read();
	while (t--)
	{
		n=read();
		for (i=1;i<=n;i++) a[i]=read();
		ans=0;num=0;
		for (i=1;i<=n;i++) vis[i]=1;
		for (i=2;i<=n;i++)
			if (a[i]>a[i-1]) num++;
				else break;
		for (;i<=n;i++)
		{
			if (vis[a[i]]==1) num--,vis[a[i]]=0;
			if (a[i]<a[i-1])
			{
				if (num>1) num--;
					else ans++;
			}
			else
			{
				num++;
			}
		}
		cout<<ans+1<<endl;
//		d[1]=a[1];
//		len=1;
//		for (i=2;i<=n;i++)
//		{
//			if (a[i]<d[len]) d[++len]=a[i];
//			else
//			{
//			    int j=lower_bound(d+1,d+len+1,a[i],cmp)-d;  //找到第一个大于它的d的下标
//            	d[j]=a[i];
//			}
//		}
//		cout<<len<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define debug freopen("r.txt","r",stdin)
#define mp make_pair
#define ri register int
#define pb push_back
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> pii;
const int maxn = 1e6+10;
const ll INF = 1e18;
const int mod = 1e9+7;
const double eps=1e-6;
const double PI=acos(-1.0);
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;}
ll qpow(ll p,ll q){return (q&1?p:1)*(q?qpow(p*p%mod,q/2):1)%mod;}
int t,n,a[maxn],dp[maxn],now,i,j;
int main()
{
	t=read();
	while (t--)
	{
		n=read();
		for (i=1;i<=n;i++) a[i]=read();
		now=1;
		for (i=2;i<=n;i=j)
		{
			dp[i]=dp[now]+1;
			for (j=i+1;j<=n&&a[j]>a[j-1];j++) dp[j]=dp[now]+1;
			now++;
		}
		cout<<dp[n]<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define debug freopen("r.txt","r",stdin)
#define mp make_pair
#define ri register int
#define pb push_back
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> pii;
const int maxn = 1e3+10;
const ll INF = 1e18;
const int mod = 1e9+7;
const double eps=1e-6;
const double PI=acos(-1.0);
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;}
ll qpow(ll p,ll q){return (q&1?p:1)*(q?qpow(p*p%mod,q/2):1)%mod;}
int t,n,a[maxn],i,ans,num,len,d[maxn];
bool cmp(int x,int y)
{
	return x > y;
}
int main()
{
	t=read();
	while (t--)
	{
		n=read();
		for (i=1;i<=n;i++) a[i]=read();
//		ans=0;num=0;
//		for (i=2;i<=n;i++)
//			if (a[i]>a[i-1]) num++;
//				else break;
//		for (;i<=n;i++)
//		{
//			if (a[i]<a[i-1])
//			{
//				if (num>1) num--;
//					else ans++;
//			}
//			else
//			{
//				num++;
//			}
//		}
//		cout<<ans+1<<endl;
		d[1]=a[1];
		len=1;
		for (i=2;i<=n;i++)
		{
			if (a[i]<d[len]) d[++len]=a[i];
			else
			{
			    int j=lower_bound(d+1,d+len+1,a[i],cmp)-d;  //找到第一个大于它的d的下标
            	d[j]=a[i];
			}
		}
		cout<<len<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define m(a) memset(a,0,sizeof(a))
int a[200005];
vector<int>q;
int main(){
    int t;cin>>t;
    while(t--){
        q.clear();
        int n;cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        if(n==2){
            cout<<1<<endl;
            continue;
        }
        int ans=1;
        int sum=0;

        for(int i=2;i<=n;i++){
            if(a[i]>a[i-1]){
                sum++;
            }
            else{
                q.push_back(sum);
                sum=1;
            }
        }
        q.push_back(sum);
        if(q.size()==1){
            cout<<1<<endl;
            continue;
        }
        int last=q[0];
        int nows=0;
        int num=0;
        ans=2;
        for(int i=1;i<q.size();i++){
            if(num<last){
                nows+=q[i];
                num++;
            }
            else{
                ans++;
                last=nows;
                num=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define m(a) memset(a,0,sizeof(a))
int a[200005];
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        int sum=0;
        int cnt=1;
        int ans=1;
        int flag=1;
        if(n==2){
            cout<<1<<endl;
            continue;
        }
        for(int i=3;i<=n;i++){
            if(a[i]>a[i-1]){
                cnt++;
                flag=1;
                continue;
            }
            else{
                if(flag==1){
                    ans++;
                    cnt=1;
                    flag=0;
                    continue;
                }
                cnt--;
                if(cnt==0){
                    flag=1;
                    ans++;
                    cnt=1;
                }
            }
        }
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define m(a) memset(a,0,sizeof(a))
int a[200005];
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        if(n==2){
            cout<<1<<endl;
            continue;
        }
        int last=1;
        int ans=1;
        int nows=0;
        for(int i=3;i<=n;i++){
            if(a[i]>a[i-1]){
                last++;
            }
            else{
                nows++;
                if(nows==1)ans++;
                else if(nows>last){
                    last=1;
                    nows=0;
                    ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define m(a) memset(a,0,sizeof(a))
int a[200005];
int f[200005];
vector<int>q;
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        queue<int>q;
        q.push(1);
        f[1]=0;
        for(int i=2;i<=n;i++){
            if(a[i]>a[i-1]){
                q.push(i);
                f[i]=f[q.front()]+1;
            }
            else{
                q.push(i);
                q.pop();
                f[i]=f[q.front()]+1;
            }
        }
        int maxs=0;
        for(int i=1;i<=n;i++)maxs=max(maxs,f[i]);
        cout<<maxs<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define m(a) memset(a,0,sizeof(a))
int a[200005];
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        int sum=0;
        int cnt=1;
        int ans=1;
        if(n==2){
            cout<<1<<endl;
            continue;
        }
        for(int i=3;i<=n;i++){
            if(a[i]>a[i-1]){
                cnt++;
                continue;
            }
            else{
                sum++;
                if(sum<=cnt)ans++,cnt=1,sum=0;
                else{
                    cnt--;
                    sum=0;
                }
            }
        }
        cout<<ans<<endl;
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int maxn = 200010;

int T,n,ans;
int a[maxn], pos[maxn], cnt, cur, now;

queue<P> q;

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	T = read();

	while(T--){
		memset(pos,0,sizeof(pos));
		n = read(); cnt = 0; cur = 2; now = 1; ans = 0;
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;++i) a[i] = read();

		for(int i=1;i<=n;++i) if(a[i] < a[i-1]) pos[++cnt] = i - 1;

		q.push(P(0,1));

		while(!q.empty()){
			P p = q.front(); q.pop();
			int dep = p.first + 1; ans = max(ans, dep);
			for(int i=cur;i<=pos[now] && now <= cnt;++i){
				q.push(P(dep,i));
			}
			++now;
		}
		if(pos[now] < n){
			P p = q.front(); q.pop();
			int dep = p.first + 1; ans = max(ans, dep);
		}
		printf("%d\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int maxn = 200010;

int T,n,ans;
int a[maxn], pos[maxn], cnt, cur, now;

int head = 1,tail = 0;
int q[maxn];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	T = read();
	while(T--){
		memset(pos,0,sizeof(pos));
		memset(q,0,sizeof(q));
		n = read(); cnt = 0; cur = 2; now = 1; ans = 0;

		for(int i=1;i<=n;++i) a[i] = read();

		head = 1; tail = 0;

		for(int i=1;i<=n;++i) if(a[i] < a[i-1]) pos[++cnt] = i - 1;

		q[++tail] = 0;

		while(head <= tail){
//			printf("q: %d %d %d %d\n",head,tail,q[head],q[tail]);
			int dep = q[head++] + 1; ans = max(ans, dep);
			for(int i=cur;i<=pos[now] && now <= cnt;++i){
				q[++tail] = dep;
			}
			if(now==cnt) break;
			++now;
		}

		ans = max(ans,q[head] + 1);

		printf("%d\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int maxn = 200010;

int T,n,ans;
int a[maxn], pos[maxn], cnt, cur, now;

queue<P> q;

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	T = read();

	while(T--){
		memset(pos,0,sizeof(pos));
		n = read(); cnt = 0; cur = 2; now = 1; ans = 0;
		for(int i=1;i<=n;++i) a[i] = read();

		for(int i=1;i<=n;++i) if(a[i] < a[i-1]) pos[++cnt] = i - 1;

//		for(int i=1;i<=cnt;++i) printf("%d ",pos[i]); printf("\n");

		q.push(P(0,1));

		while(!q.empty()){
			P p = q.front(); q.pop();
			int dep = p.first + 1; ans = max(ans, dep);
			for(int i=cur;i<=pos[now] && now <= cnt;++i){
				q.push(P(dep,i));
			}
			++now;
		}
		if(pos[now] < n){
			P p = q.front(); q.pop();
			int dep = p.first + 1; ans = max(ans, dep);
		}
		printf("%d\n",ans);
	}

	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int maxn = 200010;

int T,n,ans;
int a[maxn], pos[maxn], cnt, cur, now;

int head = 1,tail = 0;
int q[maxn];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	T = read();
	while(T--){
		memset(pos,0,sizeof(pos));
		memset(q,0,sizeof(q));
		n = read(); cnt = 0; cur = 2; now = 1; ans = 0;

		for(int i=1;i<=n;++i) a[i] = read();

		head = 1; tail = 0;

		for(int i=1;i<=n;++i) if(a[i] < a[i-1]) pos[++cnt] = i - 1;
		pos[++cnt] = n;

		q[++tail] = 0;

		while(head <= tail){
//			printf("q: %d %d %d %d\n",head,tail,q[head],q[tail]);
			int dep = q[head++] + 1; ans = max(ans, dep);
			for(cur;cur<=pos[now] && now <= cnt;++cur){
				q[++tail] = dep;
			}
			if(now == cnt) break;
			++now;
		}

		printf("%d\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int maxn = 200010;

int T,n,ans;
int a[maxn], pos[maxn], cnt, cur, now;

queue<P> q;

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	T = read();

	while(T--){
		memset(pos,0,sizeof(pos));
		n = read(); cnt = 0; cur = 2; now = 1; ans = 0;
		for(int i=1;i<=n;++i) a[i] = read();

		for(int i=1;i<=n;++i) if(a[i] < a[i-1]) pos[++cnt] = i - 1;

//		for(int i=1;i<=cnt;++i) printf("%d ",pos[i]); printf("\n");

		q.push(P(0,1));

		while(!q.empty()){
			P p = q.front(); q.pop();
			int dep = p.first + 1; ans = max(ans, dep);
			for(int i=cur;i<=pos[now] && now <= cnt;++i){
				q.push(P(dep,i));
			}
			++now;
		}
		if(pos[now] < n){
			P p = q.front(); q.pop();
			int dep = p.first + 1; ans = max(ans, dep);
		}
		printf("%d\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int maxn = 200010;

int T,n,ans;
int a[maxn], pos[maxn], cnt, cur, now;

int head = 1,tail = 0;
int q[maxn];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	T = read();
	while(T--){
		memset(pos,0,sizeof(pos));
		n = read(); cnt = 0; cur = 2; now = 1; ans = 0;

		for(int i=1;i<=n;++i) a[i] = read();

		head = 1; tail = 0;

		for(int i=1;i<=n;++i) if(a[i] < a[i-1]) pos[++cnt] = i - 1;

		q[++tail] = 0;

		while(head <= tail){
//			printf("q: %d %d %d %d\n",head,tail,q[head],q[tail]);
			int dep = q[head++] + 1; ans = max(ans, dep);
			for(int i=cur;i<=pos[now] && now <= cnt;++i){
				q[++tail] = dep;
			}
			++now;
		}

		printf("%d\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,as=0;
	cin>>n;
	int las;cin>>las;las=10000000;
	for(int i=2;i<=n;++i){
		int x;cin>>x;
		if(x<las) ++as;
		las=x;
	}
	cout<<as<<endl;
}
int main(){
	int T;cin>>T;
	while(T--) solve();
}


#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n;cin>>n;
	int as=0;
	int las=0x3f3f3f3f;
	int res1=1,res2=0;
	int x;cin>>x;
	if(n==1){
		cout<<0<<endl;
		return;
	}
	cin>>x;
	las=x;
	res2=1;++as;
	for(int i=3;i<=n;++i){
		cin>>x;
		if(x>las) ++res2;
		else{
			if(res1>1) --res1;
			else{
				res1=res2;
				res2=1;
				++as;
			}
		}
		las=x;
	}
	cout<<as<<endl;
}
int main(){
	int T;cin>>T;
	while(T--) solve();
}


#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n;cin>>n;
	int as=0;
	int las=1000000;
	int res1=1,res2=0;
	int x;cin>>x;
	for(int i=2;i<=n;++i){
		cin>>x;
		if(x>las) ++res2;
		else{
			if(res1>1) --res1;
			else{
				res1=res2;
				res2=1;
				++as;
			}
		}
		las=x;
	}
	cout<<as<<endl;
}
int main(){
	int T;cin>>T;
	while(T--) solve();
}


#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n;cin>>n;
	int as=0;
	int las=0x3f3f3f3f;
	int res1=1,res2=0;
	int x;cin>>x;
	if(n==1){
		cout<<0<<endl;
		return;
	}
	cin>>x;
	las=x;
	res2=1;++as;
	for(int i=3;i<=n;++i){
		cin>>x;
		if(x>las) ++res2;
		else{
			if(res1>1) --res1,++res2;
			else{
				res1=res2;
				res2=1;
				++as;
			}
		}
		las=x;
	}
	cout<<as<<endl;
}
int main(){
	int T;cin>>T;
	while(T--) solve();
}


#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n;cin>>n;
	int as=0;
	int las=0x3f3f3f3f;
	int res1=1,res2=1;
	int x;cin>>x;
	for(int i=2;i<=n;++i){
		cin>>x;
		if(x>las) ++res2;
		else{
			if(res1>1) --res1;
			else{
				res1=res2;
				res2=1;
				++as;
			}
		}
		las=x;
	}
	cout<<as<<endl;
}
int main(){
	int T;cin>>T;
	while(T--) solve();
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T,n,a[200001],cnt[200001];
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>n;
		cin>>a[1];
		memset(cnt,0,sizeof(cnt));
		cnt[1]=1;
		int ans=1,now=0,sum=0;
		//a[1]=0x7fffffff;
		for(register int i=2;i<=n;++i)
		{
			scanf("%d",&a[i]);
			if(a[i]<a[i-1])
			{
				cnt[ans+1]+=sum;
				sum=0;
				++now;
				if(now==cnt[ans])
				{
					now=0;
					++ans;
				}
			}
			++sum;
		}
		printf("%d\n",ans);
	}
	return 0;
}
/*1000
20
1 17 20 18 12 8 13 16 7 19 3 6 15 10 14 9 5 4 11 2*/


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T,n,a[200001],cnt[200001];
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>n;
		cin>>a[1];
		memset(cnt,0,sizeof(cnt));
		cnt[1]=1;
		int ans=1,now=0,sum=0;
		//a[1]=0x7fffffff;
		for(register int i=2;i<=n;++i)
		{
			scanf("%d",&a[i]);
			if(a[i]<a[i-1])
			{
				cnt[ans+1]+=sum;
				++now;
				if(now==cnt[ans])
				{
					now=0;
					sum=-1;
					++ans;
				}
			}
			++sum;
		}
		printf("%d\n",ans);
	}
	return 0;
}
/*1000
20
1 17 20 18 12 8 13 16 7 19 3 6 15 10 14 9 5 4 11 2*/


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T,n,a[200001],cnt[200001];
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>n;
		cin>>a[1];
		memset(cnt,0,sizeof(cnt));
		cnt[0]=1;
		int ans=1,now=0,sum=0;
		for(register int i=2;i<=n;++i)
		{
			scanf("%d",&a[i]);
			if(a[i]<a[i-1])
			{
				cnt[ans+1]+=sum;
				++now;
				if(now==cnt[ans])
				{
					now=0;
					sum=0;
					++ans;
				}
			}
			++sum;
		}
		printf("%d\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T,n,a[200001],cnt[200001];
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>n;
		cin>>a[1];
		memset(cnt,0,sizeof(cnt));
		cnt[0]=1;
		int ans=0,now=0,sum=1;
		a[1]=0x7fffffff;
		for(register int i=2;i<=n;++i)
		{
			scanf("%d",&a[i]);
			if(a[i]<a[i-1])
			{
				cnt[ans+1]+=sum;
				++now;
				if(now==cnt[ans])
				{
					now=0;
					sum=0;
					++ans;
				}
			}
			++sum;
		}
		printf("%d\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T,n,a[200001],cnt[200001];
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>n;
		cin>>a[1];
		memset(cnt,0,sizeof(cnt));
		cnt[1]=1;
		int ans=1,now=0;
		for(register int i=2;i<=n;++i)
		{
			scanf("%d",&a[i]);
			if(a[i]<a[i-1])
			{
				++cnt[ans+1];
				++now;
				if(now==cnt[ans])
				{
					now=0;
					++ans;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
const int maxn = 2e5 + 5;
long long a[maxn];

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        for (int i = 0; i < n; i++)
            cin >> a[i];
        int cnt = 0;
        for (int i = 2; i < n; i++)
        {
            if (a[i] > a[i - 1])
                continue;
            else cnt++;
        }
        cnt++;
        cout << cnt << endl;
    }
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#define EL puts("")
#define LL long long
using namespace std;
int T,n,m;
char ch[100100];
int main(){
    cin>>T;
    int l,r;
    ch[0] = 0;
    while (T--){
        int t=0,lastt,maxheight=1,curcnt=1,nextcnt=0;
        scanf("%d",&n);
        scanf("%d",&t);
        for (int i=1; i<n; i++){
            lastt = t;
            scanf("%d",&t);
            if (t>lastt){
                    nextcnt++;
                    continue;
            }
            curcnt--;
            if (curcnt==0){
                curcnt = nextcnt;
                nextcnt = 1;
                maxheight++;
            }else nextcnt++;
        }
        printf("%d\n",maxheight);
    }

    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int T;
int a[200010];
int dep[200010];
int main(){
	scanf("%d",&T);
	for(int t=1;t<=T;t++)
	{
		int n;
		int sum=2;
		int maxn=0;
		int flag=2;
		memset(dep,0,sizeof(dep));
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
		}
		if(n==1||n==2){
			cout<<n-1<<endl;
			continue;
		}
		queue<int>q;
	    q.push(a[1]);
	    dep[1]=0;
	    while(!q.empty())
	    {
	         int no=q.front();
	         q.pop();
	         while(a[sum]<a[sum+1]&&sum!=n)sum++;
	         for(int i=flag;i<=sum;i++)
	         {
	         	dep[a[i]]=dep[no]+1;
				maxn=max(maxn,dep[a[i]]);
				q.push(a[i]);
			 }
			 if(sum==n)break;
			 flag=sum+1;
			 sum++;
		}
		cout<<maxn<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,y=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*y;
}
int t,n,a[200010],dep[200010],maxx;
signed main()
{
	t=read();
	while(t--)
	{
		n=read();
		for(int i=1;i<=n;i++)
		{
			dep[i]=0;
			a[i]=read();
		}
		maxx=1;
		dep[0]=0;
		for(int i=2;i<=n;i++)
		{
			if(a[i]>a[i-1])
			dep[maxx]++;
			else
			{
				dep[maxx-1]--;
				if(dep[maxx-1]<0)
				dep[++maxx]++,dep[maxx-1]--;
				else
				dep[maxx]++;
			}
		}
		cout<<maxx<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int T;
	scanf("%d",&T);
	while(T--){
		int n,x;
		scanf("%d",&n);scanf("%d",&x);
		if(n==1){
			printf("0\n");
			continue;
		}
		scanf("%d",&x);
		int last=x,cnt=1,dep=1,shang=1,dang=1;
		for(int i=3;i<=n;i++){
			scanf("%d",&x);
			if(x>last){
				++dang;
			}
			else{
				++cnt;
				if(cnt>shang){
					dep++;
					shang=dang;
					cnt=1;
				}
			}
		}
		printf("%d\n",dep);
	}
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,n,a) for (int i=n;i>=a;i--)
#define mst(a,i) memset(a,i,sizeof a)
#define ll long long
#define pb push_back
#define eps 1e-10
#define fi first
#define se second
#define pii pair<int,int>
#define inf 0x3f3f3f3f
const int mod = 998244353;
const int N = 2e5+6;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _,n,cnt,sz,ans;
    cin>>_;
    while(_--){
    	cin>>n;
    	vector<int>pp(n);
    	queue<int>q;
    	q.push(1);
		for(int i=0;i<n;i++)
			cin>>pp[i];
		reverse(pp.begin(),pp.end());
		pp.pop_back();
		ans=0;
		while(pp.size()){
			sz=q.size();
			for(int i=0;i<sz;i++) {
				if(pp.size()==0)
					break;
				q.pop();
				cnt=pp.back();
				q.push(cnt);
				pp.pop_back();
				while (pp.size()&&cnt<pp.back()){
					q.push(pp.back());
					cnt=pp.back();
					pp.pop_back();
				}
			}
			ans++;
		}
		cout<<ans<<endl;
	}
    return 0;
}
/*
3
4
1 4 3 2
2
1 2
3
1 2 3
*/


#include <bits/stdc++.h>
#define ll long long
#define maxN 100
using namespace std;
typedef pair<int,int> ii; typedef vector<ii> vii;
typedef vector<int> vi;
void setIO(string asdf)
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    freopen((asdf + ".in").c_str(), "r", stdin);
    freopen((asdf + ".out").c_str(), "w", stdout);
}

int main()
{
    //setIO("");
    setIO("in");
    int N; cin >> N;
    while(N--)
    {
        int x; cin >> x;
        int ans = 0;
        int prev = 0;
        //for(int i = 0; i < x; i++)
        int i = 0;
        queue<int> q;
        int z; cin >> z;
        i++;
        q.push(z);
        while(!q.empty())
        {
            i++;
            if(i == x+1)
            {
                break;
            }
            int a; cin >> a;
            if(a < prev)
            {
                ans++;
                q.pop();
                prev = a;
                q.push(a);
            }
            else
            {
                prev = a;
                q.push(a);
            }

        }
        cout << ans + 1 << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define maxN 100
using namespace std;
typedef pair<int,int> ii; typedef vector<ii> vii;
typedef vector<int> vi;
void setIO(string asdf)
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    freopen((asdf + ".in").c_str(), "r", stdin);
    freopen((asdf + ".out").c_str(), "w", stdout);
}

int main()
{
    //setIO("");
    //setIO("in");
    int N; cin >> N;
    while(N--)
    {
        int x; cin >> x;
        int ans = 0;
        int prev = 0;
        //for(int i = 0; i < x; i++)
        int i = 0;
        queue<int> q;
        int z; cin >> z;
        i++;
        q.push(z);
        while(!q.empty())
        {
            i++;
            if(i == x+1)
            {
                break;
            }
            int a; cin >> a;
            if(a < prev)
            {
                ans++;
                q.pop();
                prev = a;
                q.push(a);
            }
            else
            {
                prev = a;
                q.push(a);
            }

        }
        cout << ans + 1 << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define maxN 100
using namespace std;
typedef pair<int,int> ii; typedef vector<ii> vii;
typedef vector<int> vi;
void setIO(string asdf)
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    freopen((asdf + ".in").c_str(), "r", stdin);
    freopen((asdf + ".out").c_str(), "w", stdout);
}

int main()
{
    //setIO("");
    setIO("in");
    int N; cin >> N;
    while(N--)
    {
        int x; cin >> x;
        int ans = 0;
        int prev = 0;
        //for(int i = 0; i < x; i++)
        int i = 0;
        queue<int> q;
        int z; cin >> z;
        q.push(z);
        while(!q.empty())
        {
            int a; cin >> a;
            i++;
            if(i == x)
            {
                break;
            }
            if(z < prev)
            {
                ans++;
                q.pop();
                prev = a;
                q.push(a);
            }
            else
            {
                prev = a;
                q.push(a);
            }

        }
        cout << ans + 1 << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define maxN 100
using namespace std;
typedef pair<int,int> ii; typedef vector<ii> vii;
typedef vector<int> vi;
void setIO(string asdf)
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    freopen((asdf + ".in").c_str(), "r", stdin);
    freopen((asdf + ".out").c_str(), "w", stdout);
}

int main()
{
    //setIO("");
    //setIO("in");
    int N; cin >> N;
    while(N--)
    {
        int x; cin >> x;
        int ans = 0;
        int prev = 0;
        for(int i = 0; i < x; i++)
        {
            int z; cin >> z;
            if(!i)
            {
                prev = 1000000000;
                continue;
            }
            if(z < prev)
            {
                ans++;
                prev = z;
            }
            else
            {
                prev = z;
            }

        }
        cout << ans << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define maxN 100
using namespace std;
typedef pair<int,int> ii; typedef vector<ii> vii;
typedef vector<int> vi;
void setIO(string asdf)
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    freopen((asdf + ".in").c_str(), "r", stdin);
    freopen((asdf + ".out").c_str(), "w", stdout);
}

int main()
{
    //setIO("");
    //setIO("in");
    int N; cin >> N;
    while(N--)
    {
        int x; cin >> x;
        int ans = 0;
        int prev = 100000000;
        //for(int i = 0; i < x; i++)
        int i = 0;
        queue<ii> q;
        int z; cin >> z;
        i++;
        q.push({z,0});
        while(!q.empty())
        {
            i++;
            if(i == x+1)
            {
                break;
            }
            int a; cin >> a;
            if(a < prev)
            {
                q.push({a,q.front().second+1});
                ans = max(ans, q.front().second + 1);
                q.pop();
                prev = a;

            }
            else
            {
                prev = a;
                q.push({a,q.front().second});
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define maxN 100
using namespace std;
typedef pair<int,int> ii; typedef vector<ii> vii;
typedef vector<int> vi;
void setIO(string asdf)
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    freopen((asdf + ".in").c_str(), "r", stdin);
    freopen((asdf + ".out").c_str(), "w", stdout);
}

int main()
{
    //setIO("");
    //setIO("in");
    int N; cin >> N;
    while(N--)
    {
        int x; cin >> x;
        int ans = 0;
        int prev = 0;
        //for(int i = 0; i < x; i++)
        int i = 0;
        queue<int> q;
        int z; cin >> z;
        q.push(z);
        while(!q.empty())
        {
            int a; cin >> a;
            i++;
            if(i == x)
            {
                break;
            }
            if(z < prev)
            {
                ans++;
                q.pop();
                prev = a;
                q.push(a);
            }
            else
            {
                prev = a;
                q.push(a);
            }

        }
        cout << ans + 1 << '\n';
    }
    return 0;
}


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

typedef long long ll;
#define heapmax(x) priority_queue<x>
#define heapmin(x) priority_queue<x, vector<x>, greater<x>>
#define x first
#define y second

template<typename T>inline T maximize(T &a, T b) { return a = max(a, b); }
template<typename T>inline T minimize(T &a, T b) { return a = min(a, b); }
template<typename T>inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }
template<typename T>inline T lcm(T a, T b) { return a/gcd(a, b)*b; }
template<typename T>inline T pw(T a, T n) { if (n == 1) return a; T t = pw(a, n/2); return (n & 1) ? t*t*a : t*t + 1; }
template<typename T>inline string tostr(T x) { stringstream ss;  ss << x; return ss.str(); }
template<typename T>inline T tonum(string x) { stringstream ss(x); T n; ss >> n; return n; }

#define endfunc(x) { x return;  }
#define endloop(x) { x break;   }
#define endprog(x) { x exit(0); }

template<typename T>inline void gstr(T& s) { char c; while (c = getchar(), c == ' ' || c == '\n' || c == '\t'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != ' ' && c != '\n' && c != '\t') s.push_back(c); }
template<typename T>inline void gline(T& s) { char c; while (c = getchar(), c == '\n'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != '\n') s.push_back(c); }
template<typename T>inline void gN(T& n) { char c; while (c = getchar(), c != '-' && (c < '0' || c > '9')); bool sign(c == '-'); if (sign) c = getchar(); n = c - '0'; while (c = getchar(), c >= '0' && c <= '9' ) n = 10*n + c - '0'; if (sign) n = -n; }
ll	     gll() { ll x;	   return 	     cin >> x, x; }
int	    gint() { int x;	   return 	     cin >> x, x; }
char   gchar() {		   return          getchar(); }
string  gstr() { string x; return        cin >> x, x; }
string gline() { string x; return getline(cin, x), x; }

vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); }
template<typename T, typename... Args> inline string arrStr(T arr, int n) { stringstream s; s << "["; for(int i = 0; i < n - 1; i++) s << arr[i] << ","; s << arr[n - 1] << "]"; return s.str(); }
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args> inline void __evars(vector<string>::iterator it, T a, Args... args) { cerr << it->substr((*it)[0] == ' ', it->length()) << "="; __evars_out_var(a); cerr << "; "; __evars(++it, args...); }

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
	size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); }
};

const int	 MAX  = 1 << 30;
const ll	 LMAX = 1ll << 60;
const int    MOD  = 1e9 + 7;
const double PI   = acos(-1);

		/* ------- declaration ------- */

	int n;

/* ------- ~~~~~~~~~~~ ------- */

		/* ----------------- main func ----------------- */

	void query() {
		cin >> n; gint();
		multiset < int, greater<int> > s;
	multiset < int, greater<int> > :: iterator it;
		for (int i = 1; i <= n; ++i) {
		int x = gint();
	    s.insert(x);

	    it = s.lower_bound(x);

	    it++;

	    if(it != s.end())
	        s.erase(it);
	}
		cout << s.size() << '\n';
	}

/* ----------------- ~~~~~~~~~ ----------------- */

int main(){
	//freopen("Test.INP", "r", stdin);
	//freopen("Test.OUT", "w", stdout);
	cin.tie(NULL)->sync_with_stdio(false);

		/* ------- setup ------- */

	srand(time(0));
	cout << fixed << setprecision(2);
	for (int t = gint(); t--; query());

/* ------- ~~~~~ ------- */

	return 0;
}

		/* ------- unnecessary stuff -------

	011100
	1 3 2
	1 1 1 2 1

------- ~~~~~~~~~~~~~~~~~ ------- */


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

		/* ----------------- */

typedef long long ll;
#define heapmax(x) priority_queue<x>
#define heapmin(x) priority_queue<x, vector<x>, greater<x>>
#define x first
#define y second

template<typename T>inline T maximize(T &a, T b) { return a = max(a, b); }
template<typename T>inline T minimize(T &a, T b) { return a = min(a, b); }
template<typename T>inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }
template<typename T>inline T lcm(T a, T b) { return a/gcd(a, b)*b; }
template<typename T>inline T pw(T a, T n) { if (n == 1) return a; T t = pw(a, n/2); return (n & 1) ? t*t*a : t*t + 1; }
template<typename T>inline string tostr(T x) { stringstream ss;  ss << x; return ss.str(); }
template<typename T>inline T tonum(string x) { stringstream ss(x); T n; ss >> n; return n; }

template<typename T>inline void gstr(T& s) { char c; while (c = getchar(), c == ' ' || c == '\n' || c == '\t'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != ' ' && c != '\n' && c != '\t') s.push_back(c); }
template<typename T>inline void gline(T& s) { char c; while (c = getchar(), c == '\n'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != '\n') s.push_back(c); }
template<typename T>inline void gN(T& n) { char c; while (c = getchar(), c != '-' && (c < '0' || c > '9')); bool sign(c == '-'); if (sign) c = getchar(); n = c - '0'; while (c = getchar(), c >= '0' && c <= '9' ) n = 10*n + c - '0'; if (sign) n = -n; }
ll	     gll() { ll x;	   return 	     cin >> x, x; }
int	    gint() { int x;	   return 	     cin >> x, x; }
char   gchar() {		   return          getchar(); }
string  gstr() { string x; return        cin >> x, x; }
string gline() { string x; return getline(cin, x), x; }

vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); }
template<typename T, typename... Args> inline string arrStr(T arr, int n) { stringstream s; s << "["; for(int i = 0; i < n - 1; i++) s << arr[i] << ","; s << arr[n - 1] << "]"; return s.str(); }
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args> inline void __evars(vector<string>::iterator it, T a, Args... args) { cerr << it->substr((*it)[0] == ' ', it->length()) << "="; __evars_out_var(a); cerr << "; "; __evars(++it, args...); }

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
	size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); }
};

/* ----------------- */

		/* ------- varonst ------- */

	const int	 MAX  = 1 << 30;
	const ll	 LMAX = 1ll << 60;
	const int    MOD  = 1e9 + 7;
	const double PI   = acos(-1);
	const int N = 2e5;

	int n, p;
	int a[N], d[N];

/* ------- ~~~~~~~ ------- */

		/* ----------------- main func ----------------- */

	void query() {
		cin >> n;
		for (int i = 0; i < n; ++i)
			cin >> a[i];
		p = 0;
		d[0] = 0, d[1] = 1;
		for (int i = 1; i < n; ++i) {
			if (a[i] < a[i - 1])
				++p;
			d[i] = d[p] + 1;
		}
		cout << d[n - 1] << '\n';
	}

/* ----------------- ~~~~~~~~~ ----------------- */

int main(){
	//freopen("Test.INP", "r", stdin);
	//freopen("Test.OUT", "w", stdout);
	cin.tie(NULL)->sync_with_stdio(false);

		/* ------- setup ------- */

	srand(time(0));
	cout << fixed << setprecision(2);
	for (int t = gint(); t--; query());

/* ------- ~~~~~ ------- */

	return 0;
}

/*

*/


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

typedef long long ll;
#define heapmax(x) priority_queue<x>
#define heapmin(x) priority_queue<x, vector<x>, greater<x>>
#define x first
#define y second

template<typename T>inline T maximize(T &a, T b) { return a = max(a, b); }
template<typename T>inline T minimize(T &a, T b) { return a = min(a, b); }
template<typename T>inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }
template<typename T>inline T lcm(T a, T b) { return a/gcd(a, b)*b; }
template<typename T>inline T pw(T a, T n) { if (n == 1) return a; T t = pw(a, n/2); return (n & 1) ? t*t*a : t*t + 1; }
template<typename T>inline string tostr(T x) { stringstream ss;  ss << x; return ss.str(); }
template<typename T>inline T tonum(string x) { stringstream ss(x); T n; ss >> n; return n; }

#define endfunc(x) { x return;  }
#define endloop(x) { x break;   }
#define endprog(x) { x exit(0); }

template<typename T>inline void gstr(T& s) { char c; while (c = getchar(), c == ' ' || c == '\n' || c == '\t'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != ' ' && c != '\n' && c != '\t') s.push_back(c); }
template<typename T>inline void gline(T& s) { char c; while (c = getchar(), c == '\n'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != '\n') s.push_back(c); }
template<typename T>inline void gN(T& n) { char c; while (c = getchar(), c != '-' && (c < '0' || c > '9')); bool sign(c == '-'); if (sign) c = getchar(); n = c - '0'; while (c = getchar(), c >= '0' && c <= '9' ) n = 10*n + c - '0'; if (sign) n = -n; }
ll	     gll() { ll x;	   return 	     cin >> x, x; }
int	    gint() { int x;	   return 	     cin >> x, x; }
char   gchar() {		   return          getchar(); }
string  gstr() { string x; return        cin >> x, x; }
string gline() { string x; return getline(cin, x), x; }

vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); }
template<typename T, typename... Args> inline string arrStr(T arr, int n) { stringstream s; s << "["; for(int i = 0; i < n - 1; i++) s << arr[i] << ","; s << arr[n - 1] << "]"; return s.str(); }
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args> inline void __evars(vector<string>::iterator it, T a, Args... args) { cerr << it->substr((*it)[0] == ' ', it->length()) << "="; __evars_out_var(a); cerr << "; "; __evars(++it, args...); }

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
	size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); }
};

const int	 MAX  = 1 << 30;
const ll	 LMAX = 1ll << 60;
const int    MOD  = 1e9 + 7;
const double PI   = acos(-1);

		/* ------- declaration ------- */

	int n;
	int previous, current;
	int current_group, new_group;
	int height;

/* ------- ~~~~~~~~~~~ ------- */

		/* ----------------- main func ----------------- */

	void query() {
		cin >> n >> current;
		current_group = 1;
		new_group = 0;
		height = 1;
		while (--n) {
			previous = current;
			current = gint();
			if (current > previous)
				++new_group;
			else if (current_group > 1)
				--current_group;
			else
				current_group = new_group,
				new_group = 1,
				++height;
		}
		cout << height << '\n';
	}

/* ----------------- ~~~~~~~~~ ----------------- */

int main(){
	//freopen("Test.INP", "r", stdin);
	//freopen("Test.OUT", "w", stdout);
	cin.tie(NULL)->sync_with_stdio(false);

		/* ------- setup ------- */

	srand(time(0));
	cout << fixed << setprecision(2);
	for (int t = gint(); t--; query());

/* ------- ~~~~~ ------- */

	return 0;
}

		/* ------- unnecessary stuff -------

	011100
	1 3 2
	1 1 1 2 1

------- ~~~~~~~~~~~~~~~~~ ------- */


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

typedef long long ll;
#define heapmax(x) priority_queue<x>
#define heapmin(x) priority_queue<x, vector<x>, greater<x>>
#define x first
#define y second

template<typename T>inline T maximize(T &a, T b) { return a = max(a, b); }
template<typename T>inline T minimize(T &a, T b) { return a = min(a, b); }
template<typename T>inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }
template<typename T>inline T lcm(T a, T b) { return a/gcd(a, b)*b; }
template<typename T>inline T pw(T a, T n) { if (n == 1) return a; T t = pw(a, n/2); return (n & 1) ? t*t*a : t*t + 1; }
template<typename T>inline string tostr(T x) { stringstream ss;  ss << x; return ss.str(); }
template<typename T>inline T tonum(string x) { stringstream ss(x); T n; ss >> n; return n; }

#define endfunc(x) { x return;  }
#define endloop(x) { x break;   }
#define endprog(x) { x exit(0); }

template<typename T>inline void gstr(T& s) { char c; while (c = getchar(), c == ' ' || c == '\n' || c == '\t'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != ' ' && c != '\n' && c != '\t') s.push_back(c); }
template<typename T>inline void gline(T& s) { char c; while (c = getchar(), c == '\n'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != '\n') s.push_back(c); }
template<typename T>inline void gN(T& n) { char c; while (c = getchar(), c != '-' && (c < '0' || c > '9')); bool sign(c == '-'); if (sign) c = getchar(); n = c - '0'; while (c = getchar(), c >= '0' && c <= '9' ) n = 10*n + c - '0'; if (sign) n = -n; }
ll	     gll() { ll x;	   return 	     cin >> x, x; }
int	    gint() { int x;	   return 	     cin >> x, x; }
char   gchar() {		   return          getchar(); }
string  gstr() { string x; return        cin >> x, x; }
string gline() { string x; return getline(cin, x), x; }

vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); }
template<typename T, typename... Args> inline string arrStr(T arr, int n) { stringstream s; s << "["; for(int i = 0; i < n - 1; i++) s << arr[i] << ","; s << arr[n - 1] << "]"; return s.str(); }
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args> inline void __evars(vector<string>::iterator it, T a, Args... args) { cerr << it->substr((*it)[0] == ' ', it->length()) << "="; __evars_out_var(a); cerr << "; "; __evars(++it, args...); }

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
	size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); }
};

const int	 MAX  = 1 << 30;
const ll	 LMAX = 1ll << 60;
const int    MOD  = 1e9 + 7;
const double PI   = acos(-1);

		/* ------- declaration ------- */

	int n;
	multiset < int, greater<int> > s;
	multiset < int, greater<int> > :: iterator it;

/* ------- ~~~~~~~~~~~ ------- */

		/* ----------------- main func ----------------- */

	void query() {
		cin >> n; gint();
		s.clear();
		for (int i = 2; i <= n; ++i) {
			int x = gint();
	    	s.insert(x);

	    	it = s.lower_bound(x);

	    	it++;

	    	if(it != s.end())
	        	s.erase(it);
		}
		cout << s.size() << '\n';
	}

/* ----------------- ~~~~~~~~~ ----------------- */

int main(){
	//freopen("Test.INP", "r", stdin);
	//freopen("Test.OUT", "w", stdout);
	cin.tie(NULL)->sync_with_stdio(false);

		/* ------- setup ------- */

	srand(time(0));
	cout << fixed << setprecision(2);
	for (int t = gint(); t--; query());

/* ------- ~~~~~ ------- */

	return 0;
}

		/* ------- unnecessary stuff -------

	011100
	1 3 2
	1 1 1 2 1

------- ~~~~~~~~~~~~~~~~~ ------- */


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

typedef long long ll;
#define heapmax(x) priority_queue<x>
#define heapmin(x) priority_queue<x, vector<x>, greater<x>>
#define x first
#define y second

template<typename T>inline T maximize(T &a, T b) { return a = max(a, b); }
template<typename T>inline T minimize(T &a, T b) { return a = min(a, b); }
template<typename T>inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }
template<typename T>inline T lcm(T a, T b) { return a/gcd(a, b)*b; }
template<typename T>inline T pw(T a, T n) { if (n == 1) return a; T t = pw(a, n/2); return (n & 1) ? t*t*a : t*t + 1; }
template<typename T>inline string tostr(T x) { stringstream ss;  ss << x; return ss.str(); }
template<typename T>inline T tonum(string x) { stringstream ss(x); T n; ss >> n; return n; }

#define endfunc(x) { x return;  }
#define endloop(x) { x break;   }
#define endprog(x) { x exit(0); }

template<typename T>inline void gstr(T& s) { char c; while (c = getchar(), c == ' ' || c == '\n' || c == '\t'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != ' ' && c != '\n' && c != '\t') s.push_back(c); }
template<typename T>inline void gline(T& s) { char c; while (c = getchar(), c == '\n'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != '\n') s.push_back(c); }
template<typename T>inline void gN(T& n) { char c; while (c = getchar(), c != '-' && (c < '0' || c > '9')); bool sign(c == '-'); if (sign) c = getchar(); n = c - '0'; while (c = getchar(), c >= '0' && c <= '9' ) n = 10*n + c - '0'; if (sign) n = -n; }
ll	     gll() { ll x;	   return 	     cin >> x, x; }
int	    gint() { int x;	   return 	     cin >> x, x; }
char   gchar() {		   return          getchar(); }
string  gstr() { string x; return        cin >> x, x; }
string gline() { string x; return getline(cin, x), x; }

vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); }
template<typename T, typename... Args> inline string arrStr(T arr, int n) { stringstream s; s << "["; for(int i = 0; i < n - 1; i++) s << arr[i] << ","; s << arr[n - 1] << "]"; return s.str(); }
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args> inline void __evars(vector<string>::iterator it, T a, Args... args) { cerr << it->substr((*it)[0] == ' ', it->length()) << "="; __evars_out_var(a); cerr << "; "; __evars(++it, args...); }

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
	size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); }
};

const int	 MAX  = 1 << 30;
const ll	 LMAX = 1ll << 60;
const int    MOD  = 1e9 + 7;
const double PI   = acos(-1);

		/* ------- declaration ------- */

	int n;

/* ------- ~~~~~~~~~~~ ------- */

		/* ----------------- main func ----------------- */

	void query() {
		cin >> n; gint();
		multiset < int, greater<int> > s;
		multiset < int, greater<int> > :: iterator it;
		for (int i = 1; i <= n; ++i) {
			int x = gint();
	    	s.insert(x);

	    	it = s.lower_bound(x);

	    	it++;

	    	if(it != s.end())
	        	s.erase(it);
		}
		cout << s.size() << '\n';
	}

/* ----------------- ~~~~~~~~~ ----------------- */

int main(){
	//freopen("Test.INP", "r", stdin);
	//freopen("Test.OUT", "w", stdout);
	cin.tie(NULL)->sync_with_stdio(false);

		/* ------- setup ------- */

	srand(time(0));
	cout << fixed << setprecision(2);
	for (int t = gint(); t--; query());

/* ------- ~~~~~ ------- */

	return 0;
}

		/* ------- unnecessary stuff -------

	011100
	1 3 2
	1 1 1 2 1

------- ~~~~~~~~~~~~~~~~~ ------- */


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

typedef long long ll;
#define heapmax(x) priority_queue<x>
#define heapmin(x) priority_queue<x, vector<x>, greater<x>>
#define x first
#define y second

template<typename T>inline T maximize(T &a, T b) { return a = max(a, b); }
template<typename T>inline T minimize(T &a, T b) { return a = min(a, b); }
template<typename T>inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }
template<typename T>inline T lcm(T a, T b) { return a/gcd(a, b)*b; }
template<typename T>inline T pw(T a, T n) { if (n == 1) return a; T t = pw(a, n/2); return (n & 1) ? t*t*a : t*t + 1; }
template<typename T>inline string tostr(T x) { stringstream ss;  ss << x; return ss.str(); }
template<typename T>inline T tonum(string x) { stringstream ss(x); T n; ss >> n; return n; }

#define endfunc(x) { x return;  }
#define endloop(x) { x break;   }
#define endprog(x) { x exit(0); }

template<typename T>inline void gstr(T& s) { char c; while (c = getchar(), c == ' ' || c == '\n' || c == '\t'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != ' ' && c != '\n' && c != '\t') s.push_back(c); }
template<typename T>inline void gline(T& s) { char c; while (c = getchar(), c == '\n'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != '\n') s.push_back(c); }
template<typename T>inline void gN(T& n) { char c; while (c = getchar(), c != '-' && (c < '0' || c > '9')); bool sign(c == '-'); if (sign) c = getchar(); n = c - '0'; while (c = getchar(), c >= '0' && c <= '9' ) n = 10*n + c - '0'; if (sign) n = -n; }
ll	     gll() { ll x;	   return 	     cin >> x, x; }
int	    gint() { int x;	   return 	     cin >> x, x; }
char   gchar() {		   return          getchar(); }
string  gstr() { string x; return        cin >> x, x; }
string gline() { string x; return getline(cin, x), x; }

vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); }
template<typename T, typename... Args> inline string arrStr(T arr, int n) { stringstream s; s << "["; for(int i = 0; i < n - 1; i++) s << arr[i] << ","; s << arr[n - 1] << "]"; return s.str(); }
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args> inline void __evars(vector<string>::iterator it, T a, Args... args) { cerr << it->substr((*it)[0] == ' ', it->length()) << "="; __evars_out_var(a); cerr << "; "; __evars(++it, args...); }

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
	size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); }
};

const int	 MAX  = 1 << 30;
const ll	 LMAX = 1ll << 60;
const int    MOD  = 1e9 + 7;
const double PI   = acos(-1);

		/* ------- declaration ------- */

	int n;
	int previous, current;
	int current_group, new_group;
	int height;

/* ------- ~~~~~~~~~~~ ------- */

		/* ----------------- main func ----------------- */

	void query() {
		cin >> n >> current;
		current_group = 1;
		new_group = 0;
		height = 1;
		while (--n) {
			previous = current;
			current = gint();
			if (current > previous)
				++new_group;
			else if (current_group > 1)
				--current_group;
			else
				current_group = new_group - 1,
				new_group = 1,
				++height;
		}
		cout << height << '\n';
	}

/* ----------------- ~~~~~~~~~ ----------------- */

int main(){
	//freopen("Test.INP", "r", stdin);
	//freopen("Test.OUT", "w", stdout);
	cin.tie(NULL)->sync_with_stdio(false);

		/* ------- setup ------- */

	srand(time(0));
	cout << fixed << setprecision(2);
	for (int t = gint(); t--; query());

/* ------- ~~~~~ ------- */

	return 0;
}

		/* ------- unnecessary stuff -------

	011100
	1 3 2
	1 1 1 2 1

------- ~~~~~~~~~~~~~~~~~ ------- */


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

typedef long long ll;
#define heapmax(x) priority_queue<x>
#define heapmin(x) priority_queue<x, vector<x>, greater<x>>
#define x first
#define y second

template<typename T>inline T maximize(T &a, T b) { return a = max(a, b); }
template<typename T>inline T minimize(T &a, T b) { return a = min(a, b); }
template<typename T>inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }
template<typename T>inline T lcm(T a, T b) { return a/gcd(a, b)*b; }
template<typename T>inline T pw(T a, T n) { if (n == 1) return a; T t = pw(a, n/2); return (n & 1) ? t*t*a : t*t + 1; }
template<typename T>inline string tostr(T x) { stringstream ss;  ss << x; return ss.str(); }
template<typename T>inline T tonum(string x) { stringstream ss(x); T n; ss >> n; return n; }

#define endfunc(x) { x return;  }
#define endloop(x) { x break;   }
#define endprog(x) { x exit(0); }

template<typename T>inline void gstr(T& s) { char c; while (c = getchar(), c == ' ' || c == '\n' || c == '\t'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != ' ' && c != '\n' && c != '\t') s.push_back(c); }
template<typename T>inline void gline(T& s) { char c; while (c = getchar(), c == '\n'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != '\n') s.push_back(c); }
template<typename T>inline void gN(T& n) { char c; while (c = getchar(), c != '-' && (c < '0' || c > '9')); bool sign(c == '-'); if (sign) c = getchar(); n = c - '0'; while (c = getchar(), c >= '0' && c <= '9' ) n = 10*n + c - '0'; if (sign) n = -n; }
ll	     gll() { ll x;	   return 	     cin >> x, x; }
int	    gint() { int x;	   return 	     cin >> x, x; }
char   gchar() {		   return          getchar(); }
string  gstr() { string x; return        cin >> x, x; }
string gline() { string x; return getline(cin, x), x; }

vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); }
template<typename T, typename... Args> inline string arrStr(T arr, int n) { stringstream s; s << "["; for(int i = 0; i < n - 1; i++) s << arr[i] << ","; s << arr[n - 1] << "]"; return s.str(); }
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args> inline void __evars(vector<string>::iterator it, T a, Args... args) { cerr << it->substr((*it)[0] == ' ', it->length()) << "="; __evars_out_var(a); cerr << "; "; __evars(++it, args...); }

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
	size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); }
};

const int	 MAX  = 1 << 30;
const ll	 LMAX = 1ll << 60;
const int    MOD  = 1e9 + 7;
const double PI   = acos(-1);

		/* ------- declaration ------- */

	int n;

/* ------- ~~~~~~~~~~~ ------- */

		/* ----------------- main func ----------------- */

	void query() {
		cin >> n;
		multiset < int > s;
	multiset < int > :: iterator it;
		for (int i = 1; i <= n; ++i) {
		int x = gint();
	    s.insert(x);

	    it = s.lower_bound(x);

	    it++;

	    if(it != s.end())
	        s.erase(it);
	}
		cout << s.size() - 1;
	}

/* ----------------- ~~~~~~~~~ ----------------- */

int main(){
	//freopen("Test.INP", "r", stdin);
	//freopen("Test.OUT", "w", stdout);
	cin.tie(NULL)->sync_with_stdio(false);

		/* ------- setup ------- */

	srand(time(0));
	cout << fixed << setprecision(2);
	for (int t = gint(); t--; query());

/* ------- ~~~~~ ------- */

	return 0;
}

		/* ------- unnecessary stuff -------

	011100
	1 3 2
	1 1 1 2 1

------- ~~~~~~~~~~~~~~~~~ ------- */


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

typedef long long ll;
#define heapmax(x) priority_queue<x>
#define heapmin(x) priority_queue<x, vector<x>, greater<x>>
#define x first
#define y second

template<typename T>inline T maximize(T &a, T b) { return a = max(a, b); }
template<typename T>inline T minimize(T &a, T b) { return a = min(a, b); }
template<typename T>inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }
template<typename T>inline T lcm(T a, T b) { return a/gcd(a, b)*b; }
template<typename T>inline T pw(T a, T n) { if (n == 1) return a; T t = pw(a, n/2); return (n & 1) ? t*t*a : t*t + 1; }
template<typename T>inline string tostr(T x) { stringstream ss;  ss << x; return ss.str(); }
template<typename T>inline T tonum(string x) { stringstream ss(x); T n; ss >> n; return n; }

#define endfunc(x) { x return;  }
#define endloop(x) { x break;   }
#define endprog(x) { x exit(0); }

template<typename T>inline void gstr(T& s) { char c; while (c = getchar(), c == ' ' || c == '\n' || c == '\t'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != ' ' && c != '\n' && c != '\t') s.push_back(c); }
template<typename T>inline void gline(T& s) { char c; while (c = getchar(), c == '\n'); s.clear(); s.push_back(c); while (c = getchar(), c != EOF && c != '\n') s.push_back(c); }
template<typename T>inline void gN(T& n) { char c; while (c = getchar(), c != '-' && (c < '0' || c > '9')); bool sign(c == '-'); if (sign) c = getchar(); n = c - '0'; while (c = getchar(), c >= '0' && c <= '9' ) n = 10*n + c - '0'; if (sign) n = -n; }
ll	     gll() { ll x;	   return 	     cin >> x, x; }
int	    gint() { int x;	   return 	     cin >> x, x; }
char   gchar() {		   return          getchar(); }
string  gstr() { string x; return        cin >> x, x; }
string gline() { string x; return getline(cin, x), x; }

vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); }
template<typename T, typename... Args> inline string arrStr(T arr, int n) { stringstream s; s << "["; for(int i = 0; i < n - 1; i++) s << arr[i] << ","; s << arr[n - 1] << "]"; return s.str(); }
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args> inline void __evars(vector<string>::iterator it, T a, Args... args) { cerr << it->substr((*it)[0] == ' ', it->length()) << "="; __evars_out_var(a); cerr << "; "; __evars(++it, args...); }

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
	size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); }
};

const int	 MAX  = 1 << 30;
const ll	 LMAX = 1ll << 60;
const int    MOD  = 1e9 + 7;
const double PI   = acos(-1);

		/* ------- declaration ------- */

	int n;

/* ------- ~~~~~~~~~~~ ------- */

		/* ----------------- main func ----------------- */

	void query() {
		cin >> n; gint();
		multiset < int, greater<int> > s;
		multiset < int, greater<int> > :: iterator it;
		for (int i = 2; i <= n; ++i) {
			int x = gint();
	    	s.insert(x);

	    	it = s.lower_bound(x);

	    	it++;

	    	if(it != s.end())
	        	s.erase(it);
		}
		cout << s.size() << '\n';
	}

/* ----------------- ~~~~~~~~~ ----------------- */

int main(){
	//freopen("Test.INP", "r", stdin);
	//freopen("Test.OUT", "w", stdout);
	cin.tie(NULL)->sync_with_stdio(false);

		/* ------- setup ------- */

	srand(time(0));
	cout << fixed << setprecision(2);
	for (int t = gint(); t--; query());

/* ------- ~~~~~ ------- */

	return 0;
}

		/* ------- unnecessary stuff -------

	011100
	1 3 2
	1 1 1 2 1

------- ~~~~~~~~~~~~~~~~~ ------- */


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
int n, arr[maxn];
// len  i
vector<int> vec;
void solve () {
    vec.clear();
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) scanf("%d", &arr[i]);
    int res = 0;
    for (int i = 2; i <= n; ++ i) {
        if(arr[i] >= arr[i - 1]) {
            ++ res;
        } else {
            vec.emplace_back(res);
            res = 1;
        }
    }
    if(res) vec.emplace_back(res);
    int pre = 1, ans = 0, sum = 0;
    for (int i = 0; i < vec.size(); ) {
        ++ ans;
       // cout << pre << ' ' << i << endl;
        while(pre --) {
            sum += vec[i];
            ++ i;
            if(i > vec.size()) break;
        }
        pre = sum;
        sum = 0;
    }
    printf("%d\n", ans);
}
int main () {
    int T = 1; scanf("%d", &T);
    while(T --) {
        solve ();
    }
    #ifdef iyua
        system("pause");
    #endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n, arr[maxn];
void solve () {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) scanf("%d", &arr[i]);
    int res = 0, cnt = 0;
    for (int i = 2; i <= n; ++ i) {
        if(arr[i] < arr[i - 1]) {
            ++ cnt;
        } else {
            cnt = 1;
        }
        res = max(res, cnt);
    }
    printf("%d\n", res);
}
int main () {
    int T = 1; scanf("%d", &T);
    while(T --) {
        solve ();
    }
    #ifdef iyua
        system("pause");
    #endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
int n, arr[maxn];
void solve () {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) scanf("%d", &arr[i]);
    arr[0] = inf;
    int res = 0, cnt = 0;
    for (int i = 1; i <= n; ++ i) {
        if(arr[i] < arr[i - 1]) {
            ++ res;
        }
    }
    printf("%d\n", res);
}
int main () {
    int T = 1; scanf("%d", &T);
    while(T --) {
        solve ();
    }
    #ifdef iyua
        system("pause");
    #endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
int n, arr[maxn];
void solve () {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) scanf("%d", &arr[i]);
    int res = 0, cnt = 0, last = 1;
    for (int i = 2; i <= n; ) {
        // cout << i << ' ' << last << ' ' << cnt << endl;
        if(!cnt) {
            cnt = last;
            last = 0;
            ++ res;
        }
        int j = i;
        while(i <= n && arr[i] >= arr[i - 1]) ++ i, ++ last;
        if(j == i) ++ i;
        -- cnt;
    }
    printf("%d\n", res);
}
int main () {
    int T = 1; scanf("%d", &T);
    while(T --) {
        solve ();
    }
    #ifdef iyua
        system("pause");
    #endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
int n, arr[maxn];
// len  i
vector<int> vec;
void solve () {
    vec.clear();
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) scanf("%d", &arr[i]);
    int res = 0;
    for (int i = 2; i <= n; ++ i) {
        if(arr[i] >= arr[i - 1]) {
            ++ res;
        } else {
            vec.emplace_back(res);
            res = 1;
        }
    }
    if(res) vec.emplace_back(res);
    int pre = 1, ans = 0, sum = 0;
    for (int i = 0; i < vec.size(); ) {
        ++ ans;
       // cout << pre << ' ' << i << endl;
        while(pre --) {
            sum += vec[i];
            ++ i;
            if(i > vec.size()) break;
        }
        pre = sum;
    }
    printf("%d\n", ans);
}
int main () {
    int T = 1; scanf("%d", &T);
    while(T --) {
        solve ();
    }
    #ifdef iyua
        system("pause");
    #endif
    return 0;
}


// Problem: D. Minimal Height Tree
// Contest: Codeforces - Educational Codeforces Round 97 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1437/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define mkp(x,y) make_pair(x,y)
#define maxn 200005

using namespace std;

int n,a[maxn];

int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		int ans=1;
		scanf("%d",&n);
		for( int i=0;i<n;i++) scanf("%d",&a[i]);
		if (n==1)
		{
			printf("0\n");
			continue;
		}
		for (int i=1;i<n;i++)
		{
			if (a[i]>a[i-1]) continue;
			ans++;
		}
		printf("%d\n",ans);
	}
    return 0;
}


// Problem: D. Minimal Height Tree
// Contest: Codeforces - Educational Codeforces Round 97 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1437/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define mkp(x,y) make_pair(x,y)
#define maxn 200005

using namespace std;

int n,a[maxn];

int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		int ans=1;
		scanf("%d",&n);
		for( int i=0;i<n;i++) scanf("%d",&a[i]);
		for (int i=1;i<n;i++)
		{
			if (a[i]>a[i-1]) continue;
			ans++;
		}
		printf("%d\n",ans);
	}
    return 0;
}


// Problem: D. Minimal Height Tree
// Contest: Codeforces - Educational Codeforces Round 97 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1437/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define mkp(x,y) make_pair(x,y)
#define maxn 200005

using namespace std;

int n,a[maxn],num[maxn];

int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		int ans=1;
		scanf("%d",&n);
		int p=0;
		for( int i=0;i<n;i++) scanf("%d",&a[i]);
		for (int i=0;i<=n=1;i++) num[i]=0;
		for (int i=1;i<n;i++)
		{
			if (a[i]>a[i-1])
			{
				num[p+1]++;
				continue;
			}
			if (!num[p]) p++,ans++,num[p+1]++;
			num[p]--;
		}
		printf("%d\n",ans);
	}
    return 0;
}


// Problem: D. Minimal Height Tree
// Contest: Codeforces - Educational Codeforces Round 97 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1437/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define mkp(x,y) make_pair(x,y)
#define maxn 200005

using namespace std;

int n,a[maxn],num[maxn];

int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		int ans=1;
		scanf("%d",&n);
		int p=0;
		for( int i=0;i<n;i++) scanf("%d",&a[i]);
		for (int i=0;i<=n+1;i++) num[i]=0;
		for (int i=1;i<n;i++)
		{
			if (a[i]>a[i-1])
			{
				num[p+1]++;
				continue;
			}
			if (!num[p]) p++,ans++;
			num[p]--; num[p+1]++;
		}
		printf("%d\n",ans);
	}
    return 0;
}


// Problem: D. Minimal Height Tree
// Contest: Codeforces - Educational Codeforces Round 97 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1437/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define mkp(x,y) make_pair(x,y)
#define maxn 200005

using namespace std;

int n,a[maxn],num[maxn];

int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		int ans=1;
		scanf("%d",&n);
		int p=0;
		for( int i=0;i<n;i++) scanf("%d",&a[i]);
		for (int i=0;i<=n;i++) num[i]=0;
		for (int i=1;i<n;i++)
		{
			if (a[i]>a[i-1])
			{
				num[p+1]++;
				continue;
			}
			if (!num[p]) p++,ans++;
			num[p]--;
		}
		printf("%d\n",ans);
	}
    return 0;
}


// Problem: D. Minimal Height Tree
// Contest: Codeforces - Educational Codeforces Round 97 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1437/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define mkp(x,y) make_pair(x,y)
#define maxn 200005

using namespace std;

int n,a[maxn],num[maxn];

int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		int ans=1;
		scanf("%d",&n);
		int p=0;
		for( int i=0;i<n;i++) scanf("%d",&a[i]);
		for (int i=0;i<=n;i++) num[i]=0;
		for (int i=1;i<n;i++)
		{
			if (a[i]>a[i-1])
			{
				num[p+1]++;
				continue;
			}
			if (!num[p]) p++,ans++,num[p+1]++;
			num[p]--;
		}
		printf("%d\n",ans);
	}
    return 0;
}


// Problem: D. Minimal Height Tree
// Contest: Codeforces - Educational Codeforces Round 97 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1437/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define mkp(x,y) make_pair(x,y)
#define maxn 400005

using namespace std;

int n,a[maxn],num[maxn];

int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		int ans=1;
		scanf("%d",&n);
		int p=0;
		for( int i=0;i<n;i++) scanf("%d",&a[i]);
		for (int i=0;i<=n+1;i++) num[i]=0;
		for (int i=1;i<n;i++)
		{
			if (a[i]>a[i-1])
			{
				num[p+1]++;
				continue;
			}
			if (!num[p]) p++,ans++,num[p+1]++;
			num[p]--;
		}
		printf("%d\n",ans);
	}
    return 0;
}


// Problem: D. Minimal Height Tree
// Contest: Codeforces - Educational Codeforces Round 97 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1437/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define mkp(x,y) make_pair(x,y)
#define maxn 200005

using namespace std;

int n,a[maxn],num[maxn];

int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		int ans=1;
		scanf("%d",&n);
		int p=0;
		for( int i=0;i<n;i++) scanf("%d",&a[i]);
		for (int i=0;i<=n+1;i++) num[i]=0;
		for (int i=1;i<n;i++)
		{
			if (a[i]>a[i-1])
			{
				num[p+1]++;
				continue;
			}
			if (!num[p]) p++,ans++,printf("%d %d\n",p,num[p]);
			num[p]--; num[p+1]++;
		}
		printf("%d\n",ans);
	}
    return 0;
}


// Problem: D. Minimal Height Tree
// Contest: Codeforces - Educational Codeforces Round 97 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1437/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define LL long long
#define mkp(x,y) make_pair(x,y)
#define maxn 200005

using namespace std;

int n,a[maxn],num[maxn];

int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	{
		int ans=1;
		scanf("%d",&n);
		num[0]=num[1]=0; int p=0;
		for( int i=0;i<n;i++) scanf("%d",&a[i]);
		for (int i=1;i<n;i++)
		{
			if (a[i]>a[i-1])
			{
				num[p+1]++;
				continue;
			}
			if (!num[p]) p++,ans++;
			num[p]--;
		}
		printf("%d\n",ans);
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int res=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')res=res*10+ch-48,ch=getchar();
	return res*f;
}
const int maxn = 400005;
int t;
int a[maxn];
signed main(){
	t=read();
	while(t--){
		int n=read();
		for(register int i=1;i<=n;i++)
		a[i]=read();
		a[n+1]=-1;
		int cnt=0,now=1,ans=0;
		for(register int i = 2;i<=n;i++){
			cnt++;
			if(a[i]>=a[i+1])now--;
			if(i==n&&now!=0)ans++;
			if(!now){
				ans++;
				now=cnt;
				cnt=0;
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int res=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')res=res*10+ch-48,ch=getchar();
	return res*f;
}
const int maxn = 200005;
int a[maxn],ans,t,f[maxn];
signed main(){
	t=read();
	while(t--){
		memset(f,0,sizeof f);
		int len = 0;
		int n=read();
		for(register int i=1;i<=n;i++){
			a[i]=read();
		}
		int ans = 0;
		int cnt = 1;
		int l=2;
		while(l<=n){
			ans++;

			while(a[l]>a[l-1]){
				cnt++;
				l++;
			}
			while(a[l-1]>a[l]){
				cnt--;
				l++;
			}
			if(cnt<=0)ans-=cnt,ans++;
					cnt=0;
		}
		cout<<ans<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int res=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')res=res*10+ch-48,ch=getchar();
	return res*f;
}
const int maxn = 100005;
int t;
int a[maxn];
signed main(){
	t=read();
	while(t--){
		int n=read();
		for(register int i=1;i<=n;i++)
		a[i]=read();
		a[n+1]=-1;
		int cnt=0,now=1,ans=0;
		for(register int i = 2;i<=n;i++){
			cnt++;
			if(a[i]>=a[i+1])now--;
			if(i==n&&now!=0)ans++;
			if(!now){
				ans++;
				now=cnt;
				cnt=0;
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int res=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')res=res*10+ch-48,ch=getchar();
	return res*f;
}
const int maxn = 200005;
int a[maxn],ans,t,f[maxn];
signed main(){
	t=read();
	while(t--){
		memset(f,0,sizeof f);
		int len = 1;
		int n=read();
		for(register int i=1;i<=n;i++){
			a[n-i+1]=read();
		}
		f[1]=a[1];
		for(register int i=2;i<=n;i++){
			if(a[i]>f[len])f[++len]=a[i];
			else {
				int j = lower_bound(f+1,f+1+len,a[i])-f;
				f[j] = a[i];
			}
		}
		cout<<len<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int res=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')res=res*10+ch-48,ch=getchar();
	return res*f;
}
const int maxn = 200005;
int a[maxn],ans,t,f[maxn];
signed main(){
	t=read();
	while(t--){
		memset(f,0,sizeof f);
		int len = 1;
		int n=read();
		for(register int i=1;i<=n;i++){
			a[i]=read();
		}
		a[0]=110401042;
		int cnt = 0;
		for(register int i=1;i<=n;i++){
			if(a[i]<a[i-1])cnt++;
		}
		cout<<cnt<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define YES cout<<"YES\n";return;
#define NO cout<<"NO\n";return;
#define write(a) cout<<a<<"\n";return;

using namespace std;
using vi=vector<int>;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);
    long long powmod(long long a,long long b,long long mod) {
        if (b==0 || a==1)  {if (mod==1) return 0; else return 1; }

        if (b%2==0) { long long k=powmod(a,b/2,mod); return (k*k)%mod; }
        else {long long k=powmod(a,b/2,mod); return ( (k*k) %mod *a)% mod; }
    }
    long long gcd(long long a, long long b) {
        if (a==0) return b;
        if (b==0) return a;
        if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
    }
      int prime(int p) { // 1 - простое
        for (int i=2;i*i<=p;i++) {
            if (p%i==0 && i<p) return i;
        }
        return 1;
    }

     int inv(int a, int mod) {
        return powmod(a,mod-2,mod);
    }

  int random_modul() {

    uniform_int_distribution <int> u1(1e9, 2e9);
    int pepega=u1(rnd);
    while (prime(pepega)!=1) pepega=u1(rnd);
    return pepega;
}

void ifmax(int &max, int kek) {
    if (kek>max) max=kek;
    return;
}
void ifmin(int &min, int kek) {
    if (kek<min) min=kek;
    return;
}

vector <vector<int>> digits;
int dist(vector<int> a, int digit) {
    int ans=0;
    for (int i=0;i<7;i++) { if (a[i]==1 && digits[digit][i]==0) ans=1000000; if (digits[digit][i]==1 && a[i]==0) ans++; }
    return ans;
}

    void solve () {

         /* --------- */

       int a;
       cin>>a;
       vi m(a);
       for (int i=0;i<a;i++) {
           cin>>m[i];
       }
       int d=1;
       int left=1;
       int cur=0;
       for (int i=1;i<a;i++) {
           if (m[i]<m[i-1]) {
              if (left==0) {d++; left=cur; cur=1; } else left--;
           } else cur++;
       }
       cout<<d<<"\n";

           /* --------- */
            return;
    }

    signed main() {
       ios_base::sync_with_stdio(0);
       cin.tie(0);
       cout.tie(0);

         // cout<<fixed<<setprecision(10);

          int tututu;
          tututu=1;

        cin>>tututu; // если нет запросов, то закоментить

          for (int qwerty=0;qwerty<tututu;qwerty++) solve();

        return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define YES cout<<"YES\n";return;
#define NO cout<<"NO\n";return;
#define write(a) cout<<a<<"\n";return;
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);
    long long powmod(long long a,long long b,long long mod) {
        if (b==0 || a==1)  {if (mod==1) return 0; else return 1; }

        if (b%2==0) { long long k=powmod(a,b/2,mod); return (k*k)%mod; }
        else {long long k=powmod(a,b/2,mod); return ( (k*k) %mod *a)% mod; }
    }
    long long gcd(long long a, long long b) {
        if (a==0) return b;
        if (b==0) return a;
        if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
    }
      int prime(int p) { // 1 - простое
        for (int i=2;i*i<=p;i++) {
            if (p%i==0 && i<p) return i;
        }
        return 1;
    }

     int inv(int a, int mod) {
        return powmod(a,mod-2,mod);
    }

  int random_modul() {

    uniform_int_distribution <int> u1(1e9, 2e9);
    int pepega=u1(rnd);
    while (prime(pepega)!=1) pepega=u1(rnd);
    return pepega;
}

    void solve () {

         /* --------- */

         int a;
         cin>>a;
         int m[a];
         for (int i=0;i<a;i++) cin>>m[i];
         int left=1;
         int d=0;
         int leaf=1;
         int cur=0;
         for (int i=1;i<a;i++) {
            // cout<<leaf<<" "<<cur<<" "<<d<<"\n";
             if (i==1) { leaf--; cur++; if (leaf<=0) { d++; leaf=cur-1; cur=1;  } }
            else {
                if (m[i]>m[i-1]) {cur++; }
                else {  if (leaf<=0) { d++; leaf=cur-1;  } leaf--; cur++;

                }
            }
         }
         cout<<d<<"\n";

         /* --------- */
            return;
    }

    signed main() {
       ios_base::sync_with_stdio(0);
       cin.tie(0);
       cout.tie(0);

         // cout<<fixed<<setprecision(10);

          int tututu;
          tututu=1;

         cin>>tututu; // если нет запросов, то закоментить

          for (int qwerty=0;qwerty<tututu;qwerty++) solve();

        return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define YES cout<<"YES\n";return;
#define NO cout<<"NO\n";return;
#define write(a) cout<<a<<"\n";return;

using namespace std;
using vi=vector<int>;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);
    long long powmod(long long a,long long b,long long mod) {
        if (b==0 || a==1)  {if (mod==1) return 0; else return 1; }

        if (b%2==0) { long long k=powmod(a,b/2,mod); return (k*k)%mod; }
        else {long long k=powmod(a,b/2,mod); return ( (k*k) %mod *a)% mod; }
    }
    long long gcd(long long a, long long b) {
        if (a==0) return b;
        if (b==0) return a;
        if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
    }
      int prime(int p) { // 1 - простое
        for (int i=2;i*i<=p;i++) {
            if (p%i==0 && i<p) return i;
        }
        return 1;
    }

     int inv(int a, int mod) {
        return powmod(a,mod-2,mod);
    }

  int random_modul() {

    uniform_int_distribution <int> u1(1e9, 2e9);
    int pepega=u1(rnd);
    while (prime(pepega)!=1) pepega=u1(rnd);
    return pepega;
}

void ifmax(int &max, int kek) {
    if (kek>max) max=kek;
    return;
}
void ifmin(int &min, int kek) {
    if (kek<min) min=kek;
    return;
}

vector <vector<int>> digits;
int dist(vector<int> a, int digit) {
    int ans=0;
    for (int i=0;i<7;i++) { if (a[i]==1 && digits[digit][i]==0) ans=1000000; if (digits[digit][i]==1 && a[i]==0) ans++; }
    return ans;
}

    void solve () {

         /* --------- */

       int a;
       cin>>a;
       vi m(a);
       for (int i=0;i<a;i++) {
           cin>>m[i];
       }
       int d=1;
       int left=1;
       int cur=0;
       for (int i=1;i<a;i++) {
           if (i==1 || m[i]<m[i-1]) {
              if (left==0) {d++; left=cur;  } else left--;
           } else cur++;
       }
       cout<<d<<"\n";

           /* --------- */
            return;
    }

    signed main() {
       ios_base::sync_with_stdio(0);
       cin.tie(0);
       cout.tie(0);

         // cout<<fixed<<setprecision(10);

          int tututu;
          tututu=1;

        cin>>tututu; // если нет запросов, то закоментить

          for (int qwerty=0;qwerty<tututu;qwerty++) solve();

        return 0;
    }


#include <bits/stdc++.h>
#define int long long
#define YES cout<<"YES\n";return;
#define NO cout<<"NO\n";return;
#define write(a) cout<<a<<"\n";return;

using namespace std;
using vi=vector<int>;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);
    long long powmod(long long a,long long b,long long mod) {
        if (b==0 || a==1)  {if (mod==1) return 0; else return 1; }

        if (b%2==0) { long long k=powmod(a,b/2,mod); return (k*k)%mod; }
        else {long long k=powmod(a,b/2,mod); return ( (k*k) %mod *a)% mod; }
    }
    long long gcd(long long a, long long b) {
        if (a==0) return b;
        if (b==0) return a;
        if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
    }
      int prime(int p) { // 1 - простое
        for (int i=2;i*i<=p;i++) {
            if (p%i==0 && i<p) return i;
        }
        return 1;
    }

     int inv(int a, int mod) {
        return powmod(a,mod-2,mod);
    }

  int random_modul() {

    uniform_int_distribution <int> u1(1e9, 2e9);
    int pepega=u1(rnd);
    while (prime(pepega)!=1) pepega=u1(rnd);
    return pepega;
}

void ifmax(int &max, int kek) {
    if (kek>max) max=kek;
    return;
}
void ifmin(int &min, int kek) {
    if (kek<min) min=kek;
    return;
}

vector <vector<int>> digits;
int dist(vector<int> a, int digit) {
    int ans=0;
    for (int i=0;i<7;i++) { if (a[i]==1 && digits[digit][i]==0) ans=1000000; if (digits[digit][i]==1 && a[i]==0) ans++; }
    return ans;
}

    void solve () {

         /* --------- */

       int a;
       cin>>a;
       vi m(a);
       for (int i=0;i<a;i++) {
           cin>>m[i];
       }
       int d=1;
       int left=1;
       int cur=0;
       for (int i=1;i<a;i++) {
           if (m[i]<m[i-1]) {
               left--;
              if (left==0) {d++; left=cur; cur=1; }
           } else cur++;
       }
       cout<<d<<"\n";

           /* --------- */
            return;
    }

    signed main() {
       ios_base::sync_with_stdio(0);
       cin.tie(0);
       cout.tie(0);

         // cout<<fixed<<setprecision(10);

          int tututu;
          tututu=1;

        cin>>tututu; // если нет запросов, то закоментить

          for (int qwerty=0;qwerty<tututu;qwerty++) solve();

        return 0;
    }


     int inv(int a, int mod) {
        return powmod(a,mod-2,mod);
    }

  int random_modul() {

    uniform_int_distribution <int> u1(1e9, 2e9);
    int pepega=u1(rnd);
    while (prime(pepega)!=1) pepega=u1(rnd);
    return pepega;
}

void ifmax(int &max, int kek) {
    if (kek>max) max=kek;
    return;
}
void ifmin(int &min, int kek) {
    if (kek<min) min=kek;
    return;
}

vector <vector<int>> digits;
int dist(vector<int> a, int digit) {
    int ans=0;
    for (int i=0;i<7;i++) { if (a[i]==1 && digits[digit][i]==0) ans=1000000; if (digits[digit][i]==1 && a[i]==0) ans++; }
    return ans;
}

    void solve () {

         /* --------- */

       int a;
       cin>>a;
       vi m(a);
       for (int i=0;i<a;i++) {
           cin>>m[i];
       }
       int d=1;
       int left=1;
       int cur=0;
       for (int i=1;i<a;i++) {
           if (i==1 || m[i]<m[i-1]) {
              if (left==0) {d++; left=cur; } else left--;
           } else cur++;
       }
       cout<<d<<"\n";

           /* --------- */
            return;
    }

    signed main() {
       ios_base::sync_with_stdio(0);
       cin.tie(0);
       cout.tie(0);

         // cout<<fixed<<setprecision(10);

          int tututu;
          tututu=1;

        cin>>tututu; // если нет запросов, то закоментить

          for (int qwerty=0;qwerty<tututu;qwerty++) solve();

        return 0;
    }