// Created by Priyanshu
#include <bits/stdc++.h>
#define M 1000000007
#define pi 3.14159265358979323846
#define ll long long
#define lld long double
#define ld double
#define scn(str) scanf("%s",str)
#define pri(str) printf("%s\n",str)
#define deb(x) cout<<#x<<" = "<<x<<endl
#define cel(x,a) ((x+a-1)/a)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define si set
#define sii set
#define vi vector
#define vl vector
#define vpi vector
#define vpl vector
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mina *min_element
#define mama *max_element
#define bsrch binary_search
#define ufor for
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ps(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define F first
#define S second
#define lcm(m, n) ((m/__gcd(m,n))*n)
#define inp(ar, n) for(int ele=0; ele<n; ele++)ar[ele]=read();
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define all(v) v.begin(), v.end()
#define wws(k) ww(k), putchar(’ ‘)
inline ll read() {ll sign = 1; ll x = 0; char ch; while (!isdigit(ch = getchar())) if (ch == ‘-’) sign = -1; while (isdigit(ch)) x = x * 10 + ch - ‘0’, ch = getchar(); return x * sign;}
inline void ww(ll k) { if (k < 0) putchar(’-’), k *= -1; char ch[20]; int num = 0; while (k)ch[++num] = k % 10, k /= 10; if (num == 0) ch[++num] = 0; while (num)putchar(ch[num–] + ‘0’);}
using namespace std;
const int N = 1e5 + 4;
inline void wonl() {putchar(’\n’);}
template <typename T, typename… V>
inline void wonl(T t, V… v) {ww(t); if (sizeof…(v))putchar(’ '); wonl(v…);}
int main()
{
// fast;
// clock_t time_req = clock();
int t = read();
while (t--) {
int n = read(), ar[n], cnt = 0;
inp(ar, n);
int speed = ar[0];
for (int i = 0; i < n; i++)
if (speed >= ar[i])
cnt++, speed = ar[i];
wonl(cnt);
}
// time_req = clock() - time_req;
// cout << (float)time_req / CLOCKS_PER_SEC;
return 0;
}