Problem Statement

Given a linked list A of length N and an integer B.

You need to reverse every alternate B nodes in the linked list A.

Problem Constraints

Input Format

First argument is the head pointer of the linkedlist A.

Second argument is an integer B.

Output Format

Return the head pointer of the final linkedlist as described.

Example Input

Input 1:

 A = 3 -> 4 -> 7 -> 5 -> 6 -> 6 -> 15 -> 61 -> 16
 B = 3

Input 2:

 A = 1 -> 4 -> 6 -> 6 -> 4 -> 10
 B = 2

Example Output

Output 1: