#include <iostream>
using namespace std;
int main() {
int n, m;
cin>>n>>m;
int M[n][m];
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
cin >> M[i][j];
}
}
int M1[m][n];
for(int i=0; i<m; i++) {
for(int j=0; j<n; j++) {
M1[i][j]=M[j][i];
}
}
for(int i=0; i<m; i++) {
for(int j=0; j<n; j++) {
cout<<M1[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CgkKCWludCBuLCBtOwoJY2luPj5uPj5tOwoJaW50IE1bbl1bbV07IAoJZm9yKGludCBpPTA7IGk8bjsgaSsrKSB7CgkJZm9yKGludCBqPTA7IGo8bTsgaisrKSB7CgkJCWNpbiA+PiBNW2ldW2pdOyAgCgkJfQoJfQoJaW50IE0xW21dW25dOwoJCglmb3IoaW50IGk9MDsgaTxtOyBpKyspIHsKCQlmb3IoaW50IGo9MDsgajxuOyBqKyspIHsKCQkJTTFbaV1bal09TVtqXVtpXTsKCQl9Cgl9CiAgICBmb3IoaW50IGk9MDsgaTxtOyBpKyspIHsKCQlmb3IoaW50IGo9MDsgajxuOyBqKyspIHsKCSAgICAgICAgY291dDw8TTFbaV1bal08PCIgIjsKCSAgICB9CgkgICAgY291dDw8ZW5kbDsKICAgIH0KCXJldHVybiAwOwp9