Voldemort is training his army of death eaters to finish Harry. To keep the training process easy for himself too, he wants to arrange the death eaters in the increasing order of their strength. Each death eater has some unique positive value of strength. Task is simple, he just need to sort the death eaters in the increasing order of strength. But Voldemort is not aware of any efficient sorting technique. He’s using following algorithm in order to complete the task-
- He will choose any K consecutive death eaters where K is less than or equal to total number of death eaters.
- He will then reverse the order of those K death eaters.
- He will perform above 2 operations until he found all the death eaters arranged in increasing order of their strength.
Now this is a time consuming process, so Voldemort is interested in knowing the minimum number of times he has to apply above steps so as to complete the task and if it is impossible to obtain a sorted sequence of death eaters using this technique then simply print -1 .
First line of input contains an integer T denoting number of test cases. First line of each test case contains two numbers N and K. Next line contains N space separated unique integers representing the strength of N death eaters.
Print the minimum number of times he must use his algorithm to arrange death eaters in desired order or -1 if it is impossible to obtain required sequence using given algorithm. Answer each test case in a new line.
2 5 3 5 4 1 2 3 5 4 3 2 4 1 5