// name: commute
import java.io.*;

public class Commute {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    static class TestCase {
        int n;
        int[] speeds;
    }
    
    public static TestCase read() throws java.lang.Exception {
        TestCase testCase = new TestCase();
        String[] info = br.readLine().split(" ");
        testCase.n = Integer.parseInt(info[0]);
        testCase.speeds = new int[testCase.n];
        int i = 0;
        for (String elem : info[1].split(",")) {
            testCase.speeds[i++] = Integer.parseInt(elem);
        }
        return testCase;
    }

    public static void logic(TestCase testCase) {
        // n: A positive integer denoting the number of cars on the road
        // speeds: A list of non-negative integers denoting each car's maximum driving speed
        int n = testCase.n;
        int[] speeds = testCase.speeds;
        int amt = 0;
        int curMax = Integer.MAX_VALUE;
        for (int speed : speeds) {
            if (speed < curMax) {
                amt++;
                curMax = speed;
            }
        }
        System.out.println(amt);
    }

	public static void main(String[] args) throws java.lang.Exception {
        int T = Integer.parseInt(br.readLine());
        for (int i = 0; i < T; i++) {
            logic(read());
        }
    }
}