In The Sorting Game, you are given a sequence containing a permutation of the integers between 1 and n, inclusive. In one move, you can take any k consecutive elements of the sequence and reverse their order. Find the fewest number of moves to sort the sequence in ascending order.
Consists of multiple test cases. The first line of each test case contains two integers n (2 ≤ n ≤ 8) and k (2 ≤ k ≤ n). The second line of each test case contains a permutation of numbers from 1 to n.
For each test case print in a separate line the fewest number of moves to sort the sequence in ascending order or -1 if it's impossible.