#include <iostream>
using namespace std;
int main()
{
int r, c;
int a[10000] = {0};
while (cin >> r >> c)
{
for (int i = 0; i < r * c; i++)
cin >> a[i];
for (int i = 0; i < c; i++)
{
for (int j = 0; j < r * c; j = j + c)
cout << a[i + j] << " ";
cout << endl << endl;
}
}
}