#include<iostream>
using namespace std;

int main() {
    int m, n;
    cin >> m >> n;
    int end = m % n;
    int number = (m + n - 1) / n;
    int order1[number][n];
    for (int i = 0; i < number; i++) {
        for (int j = 0; j < n; j++) {
            cin >> order1[i][j];
        }
    }
    for (int i = 0; i < end; i++) {
        cout << order1[number - 1][i] << " ";
    }
    for (int i = number - 1 - (end + n - 1) / n; i >= 0; i--) {
        for (int j = 0; j < n; j++) {
            cout << order1[i][j] << " ";
        }
    }
    return 0;
}