zinedine zidane is the manager for the legendary Real Madrid FC. Every year 20 young aspirants go to Madrid to train under zinedine zidane. He usually gives field positions based upon candidates height (short ones for defense and long ones for attack).The first few training sessions are a complete disaster since the candidates dont know where there position lies since each one is unaware of his height relative to others. zidane came up with the following plan to control the issue : one candidate would be selected to be the first person in line.Then , another student is selected and would find the FIRST person in the line that is taller than him,and stand in front of that person,thereby causing all the students behind him to step back to make room.If there is no candidate that is taller,then he would stand at the end of the line.This process continues ,one candidate at-a-time , until all candidates are in line,at which point the candidates will be lines up in height order.
you being friend of zidane need to write a program that calculates the number of steps taken back during the ordering process for a given class of students.
INPUT
First line of input consists of single integer K (1<=k<=1000) which is the number of data sets that follow . Each data set is to be calculated independently.
Each data set consists of single line of input. It contains the data set number Q, followed by 20 non-negative unique integers separated by single space.The 20 integers represent the height (in mm) of each candidates.
OUTPUT
For each data set there is one line of output. The single output line consists of data set number Q ,followed by single space followed by total number of steps taken back.
in first set all the candidates are in already in correct positions.Thus 0 steps required.
In second set for shortest person(900) to come front 19 steps in total have to be moved.similarly second shortest to come front 18 steps are needed . similarly for third shortest guy 17 steps are required and so on....so in total (19+18+17+....+3+2+1) = 190 steps required.