import java.util.Scanner;
public class Main{
public static void main(String[] args) { Scanner in = new Scanner(System.in); String[] strArr = in.nextLine().split(" "); int[] nums = new int[strArr.length]; for(int i=0; i<nums.length; i++){ nums[i] = Integer.parseInt(strArr[i]); } int k = in.nextInt(); int[] nums1 = reverseEveryKNumber(nums, k); String str = ""; for(int i=0; i<nums1.length; i++){ if(i==nums1.length-1){ str += nums1[i]; } else{ str += nums1[i] + " "; } } System.out.println(str); } public static int[] reverseEveryKNumber(int[] nums, int k){ int[] nums1 = new int[nums.length]; int[] temp = new int[k]; int count = 0; int count1 = 0; if(k>nums.length){ for(int i=0; i<nums.length; i++){ nums1[i] = nums[i]; } } else{ for(int i=0; i<nums.length; i++){ temp[count] = nums[i]; count++; if( (i+1)%k==0 ){ int[] temp1 = new int[k]; for(int j=0; j<k; j++){ temp1[j] = temp[k-j-1]; nums1[count1*k+j] = temp1[j]; } count = 0; temp = new int[k]; count1++; } if(i==nums.length-1 && i+1!=k){ for(int j=0; j<nums.length-count1*k; j++){ nums1[count1*k+j] = temp[j]; } } } } return nums1; }
}