#include
using namespace std;
int main() {
// your code goes here
int testCase;
cin >> testCase;
for( int i = 0; i < testCase; i++ ){
int NumOfCars;
cin >> NumOfCars;
int array[NumOfCars];
for( int j = 0; j < NumOfCars; j++ ){ //input of no. of cars
cin >> array[j];
}
int temp = array[0];
int count = 1;
for(int j = 1; j < NumOfCars-1; j++ ){
if( temp >= array[j] ){
count++;
temp = array[j];
}
}
cout << count << endl;
}
return 0;
}