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