#include <ios>
#include <iostream>
using namespace std;

int main() {
    int n, m, l, i = 0, j = 0;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    int a[m][n];
    while (cin >> l) {
        if (i >= m) {
            i = 0;
            j++;
        }
        a[i][j] = l;
        i++;
    }
    for (i = 0; i < m; i++) {
        for (j = 0; j < n; j++) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}
// 64 位输出请用 printf("%lld")