#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 110;
int matrix[N][N];
int main(){
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> matrix[i][j];
}
}
for(int i = 0; i < m; i++){
for(int j = n-1; j >= 0; j--){
cout << matrix[j][i] << " ";
}
cout << endl;
}
return 0;
}