An assembly line is a singly linked chain of n parts given head to tail. Reverse the parts in groups of k: reverse the first k nodes, then the next k, and so on. If the final group has fewer than k nodes, leave those nodes in their original order. Print the resulting chain.
Input format
Line 1: an integer n, the number of parts (n >= 1).
Line 2: n space-separated integers, the part values from head to tail.
Line 3: an integer k, with 1 <= k <= n.
Output format
Line 1: the number of parts, n.
Line 2: the values after reversing each full block of k, space-separated.
Constraints
- 1 <= n <= 100000
- 1 <= k <= n
- -1000000000 <= each value <= 1000000000