#include #include #include #include using namespace std; int num[38]; int pos[38]; int n,m; int main(){ int ncases ; scanf("%d",&ncases); while(ncases--){ int ans = 0; scanf("%d",&n); for(int i = 1 ;i<=n;i++ ){ scanf("%d",&num[i]) ; pos[num[i]] = i ; } for(int i = n-1;i>=1;i--){ if(pos[i]>pos[i+1]){ pos[i] = 0; ans++; } } cout<