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