Squark has a game machine, which has 2n slots in a row, numbered from 1 to 2n, inclusively. He plays a game with the machine for several rounds. In each round, he divides that row into k segments with marks at boundaries between adjacent segments. Each segment must contain an even number of slots. Then, the machine generates a random permutation of {1, 2, . . . , 2n} and displays the permutation on the slots.Finally, the machine calculates the inversion number of each segment and multiplies them together to get the score of the round. The inversion number of a sequence is the number of inversions (also called inversion pairs) in the sequence.
Squark can play the game for as many rounds as he wants, but he must use different partitions in different rounds. Two partitions are considered to be different if there is a mark somewhere in one partition but not in the other. The total game score is simply the sum of the score of each round. However, the machine has been intruded by a malware, which changes the permutation before the machine calculates the score of each round. It picks each segment and sorts the numbers in the slots numbered with even numbers.
For example, if n = 2, k = 1 and the permutation generated is (2, 4, 1, 3). The malware will pick numbers 4 and 3 (because they are in slots numbered with 2 and 4) and sort them, changing the permutation into (2, 3, 1, 4). So Squark will get a score of 2 (pairs (2, 1) and (3, 1)) in this round. Squark wants to know the maximum expected game score he can get.