speed-7

Rash is known about his love for racing sports. He is an avid Formula 1 fan. He went to watch this year's Indian Grand Prix at New Delhi. He noticed that one segment of the circuit was a long straight road. It was impossible for a car to overtake other cars on this segment. Therefore, a car had to lower down its speed if there was a slower car in front of it. While watching the race, Rash started to wonder how many cars were moving at their maximum speed.
Formally, you're given the maximum speed of N cars in the order they entered the long straight segment of the circuit. Each car will prefers to move at its maximum speed. If that's not possible because of the front car being slow, it might have to lower its speed. It still moves at the fastest possible speed while avoiding any collisions. For the purpose of this problem, you can assume that the straight segment is infinitely long.
Count the number of cars which were moving at their maximum speed on the straight segment.

Input

The first line of the input contains a single integer T denoting the number of test cases to follow. Description of each test case contains 2 lines. The first of these lines contain a single integer N, the number of cars. The second line contains N space separated integers, denoting the maximum speed of the cars in the order they entered the long straight segment.

Output

For each test case, output a single line containing the number of cars which were moving at their maximum speed on the segment.

Constraints

1 ≤ T ≤ 100
1 ≤ N ≤ 10^5 
1 ≤ speed ≤ 10^9

SAMPLE INPUT
3
1
10
3
8 3 6
5
4 5 1 2 3

SAMPLE OUTPUT
1
2
2

Source: hackerearth | Difficulty: EASY
Tags: Implementation


Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t = int(input())
for _ in range(t):
	n = int(input())
	nl = list(map(int, input().split()))
	low = nl[0]
	count = 1
	for i in range(0,n-1):
		if nl[i] >= nl[i+1]:
			count += 1
		else:
			nl[i+1] = nl[i]
	print(count)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

import sys

if __name__ == '__main__':
	data = sys.stdin.read()
	numbers = data.split("\n")
	test_cases = int(numbers[0])
	for i in range(1, test_cases*2+1 ,2):
		n_cars = int(numbers[i])
		speed_arr = []
		speed_arr = numbers[i+1].split(" ")
		speed_arr = list(int(n) for n in speed_arr[:n_cars])
		count = 0
		min = float("inf")
		if len(speed_arr) == 1:
			print(1)
		else:
			for j in range(0,len(speed_arr)):
				if min >= speed_arr[j]:
					min = speed_arr[j]
					count = count + 1
			print(count)



			


t=eval(input())
#output=[]
for i in range(t):
	n=eval(input())
	q = list(map(int, input().split()))
	#k=0
	m=0
	for k in range(n):
		x=q[k]
		if k==0:
			tmp=x
			m+=1
		else:
			if tmp>x:
				tmp=x
				m+=1
		k+=1
	print(m)
	#t-=1


t=eval(input())
for i in range(t):
	c=1
	n=eval(input())
	a=list(range(n))
	a=list(map(int, input().split()))
	max=a[0]
	for i in range(1,n):
		if(a[i]<=max):
			c=c+1
			max=a[i]
	print(c)		
		
	
	


n=eval(input())
for i in range(n):
	cars=eval(input())
	speed=list(map(int,input().strip().split(" ")))
	count=0
	minimum=speed[0]
	for i in range(1,len(speed)):
		if(speed[i]<=minimum):
			count=count+1
			minimum=speed[i]
		else:
			continue
	print(count+1)


for t in range(eval(input())):
	eval(input())
	l=list(map(int,input().split()))
	m=l[0]
	carsAtMax=1
	for x in l[1:]:
		if m>=x:
			carsAtMax+=1
			m=x
	print(carsAtMax)


cases = eval(input())

for i in range(0, cases):
	input()
	
	maxSpeed = -1
	count = 0
	speeds = list(map(int, input().split()))
	
	for speed in speeds:
		if maxSpeed == -1 or speed <= maxSpeed:
			maxSpeed = speed
			count += 1
	
	print(count)


test = int(input())

for i in range(test):
	cars = int(input())
	speed = list(map(int, input().strip().split(" ")))

	count = 1
	for i in range(1,len(speed)):
		#if speed[i] <= speed[i-1]:
		#	count += 1
		#	speed[i] = min(speed[i], speed[i-1])
		count, speed[i] = count + (1 if speed[i] <= speed[i - 1] else 0), min(speed[i], speed[i -1])

	print(count)


a=int(input())
f=[]
#print a
i=0
count=0
while(i<a):
	b=int(input())
	c=[]
	d=input().split(' ')
	if ('' in d):
		d.remove('')
	for x in d:
		x=int(x)
		c.append(x)

	if len(c)==1:
		count=1
		#print count    
		#f.append(count)        
	else:
		count=0
		while(len(c)>1):
			mini=int(c.index(min(c)))
			c=c[:mini]
			i#print c
			count=count+1
		if len(c)==1:
			count=count+1

		#print "output"
		#print count
		#f.append(count)
	i=i+1
	print(count)


if __name__ == '__main__':
	s = []
	for _ in range(eval(input())):
		N = eval(input())
		A = list(map(int, input().split()))
		S = A[:]
		for i in range(1, N):
			S[i] = min(S[i - 1], A[i])
		print(sum([1 for i, j in zip(A, S) if i == j]))


for i in range(int(input())):	
	n=eval(input());
	if n==1:	eval(input());	print(1);
	else:
		Z=list(map(int,input().split()));	min_v=Z[0];	ct=0;
		for i in Z:
			if i<=min_v:	ct+=1;	min_v=i;
		print(ct);


for _ in range(int(input())):
	_ = int(input())
	arr = list(map(int, input().split()))
	min1 = 9999999999
	count = 0
	for i in arr:
		if min1 > i:
			min1 = i
			count +=1
	print(count)


if __name__ == '__main__':
	s = []
	for _ in range(eval(input())):
		N = eval(input())
		A = list(map(int, input().split()))
		S = A[:]
		for i in range(1, N):
			S[i] = min(S[i - 1], A[i])
		print(sum([1 for i, j in zip(A, S) if i == j]))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n = int(input().strip())
for i in range(n):
	number = int(input().strip())
	cars = list(map(int, input().strip().split(" ")))
	count = 1
	minimum = cars[0]
	if number == 1:
		print(1)
	else:
		for j in cars[1:]:
			if j < minimum:
				count += 1
				minimum = j
		print(count)
			
		
		


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=int(input())
for i in range(0,t):
	n=int(input())
	y=input()
	x = list(map(int, y.split()))
#	print x
	c=1
	for j in range(1,len(x)):
		if x[j]>x[j-1]:
			x[j]=x[j-1]
		else:
			c+=1
	print(c)


T = eval(input())
res = ''
for i in range(T):
	count = 0
	N = eval(input())
	lst = [int(x) for x in input().split()]
	if len(lst)==1:
		count += 1
	else:
		count += 1
		for i in range(len(lst)-1):
			if lst[i]>=lst[i+1]:
				count += 1
			else:
				lst[i+1] = lst[i]
	res += str(count) + '\n'
print(res)
		
			


T=int(input())
for j in range(0,T):
	N=int(input())
	C=input()
	car_speed=[int(x)for x in C.split()]
	count=1
	if len(car_speed)==1:
		print(count)
	else:
		max_speed_queue=[]
		max_speed_queue.append(car_speed[0])
		for i in range(1,len(car_speed)):

			if all(car_speed[i]<x for x in max_speed_queue):
				count=count+1
			max_speed_queue.append(car_speed[i])
		print(count)







T = int(input())
results = []
for t in range(T):
	N = int(input())
	speeds = list(map(int, input().split()))
	result = 1
	maximum = speeds[0]
	for speed in speeds[1:]:
		if speed < maximum:
	   	    result += 1
			maximum = speed
	results.append(result)

for result in results:
	print(result)
	





cases = int(input())

for i in range(0, cases):
	input()
	
	maxSpeed = -1
	count = 0
	speeds = list(map(int, input().split()))
	
	for speed in speeds:
		if maxSpeed == -1 or speed <= maxSpeed:
			maxSpeed = speed
			count += 1
	
	print(count)