#include <iostream>
using namespace std;
int main()
{
int matrix[100][100];
int row,col;
while (cin >> row >> col){
for (int i=0;i<row;++i){
for (int j=0;j<col;++j){
cin >> matrix[i][j];
}
}
for (int i=0;i<col;++i){
for (int j=0;j<row;++j){
cout << matrix[j][i]; //矩陣翻轉所以此處要改成[j][i]
if (j != row - 1){ //判斷空格
cout << " ";
}
}
cout << endl;
}
}
return 0;
}