#include <iostream>
using namespace std;
int main() {
int cols,rows;
cin >> cols >> rows;
int a[cols][rows];
int b[rows][cols];
for(int i = 0; i<cols; i++){
for(int j = 0; j<rows; j++){
cin >> a[i][j];
}
}
for(int i = 0; i<rows; i++){
for(int j = 0 ; j<cols; j++){
b[i][j] = a[j][i];
}
}
for(int i = 0; i<rows; i++){
for(int j = 0; j<cols; j++){
cout << b[i][j] << " ";
}
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgY29scyxyb3dzOwoJY2luID4+IGNvbHMgPj4gcm93czsKCWludCBhW2NvbHNdW3Jvd3NdOwoJaW50IGJbcm93c11bY29sc107Cglmb3IoaW50IGkgPSAwOyBpPGNvbHM7IGkrKyl7CgkJZm9yKGludCBqID0gMDsgajxyb3dzOyBqKyspewoJCQljaW4gPj4gYVtpXVtqXTsKCQkJCgkJfQoJfQogICAgZm9yKGludCBpID0gMDsgaTxyb3dzOyBpKyspewoJCWZvcihpbnQgaiA9IDAgOyBqPGNvbHM7IGorKyl7CgkJCWJbaV1bal0gPSBhW2pdW2ldOwoJCX0KICAgIH0KCWZvcihpbnQgaSA9IDA7IGk8cm93czsgaSsrKXsKCQlmb3IoaW50IGogPSAwOyBqPGNvbHM7IGorKyl7CgkJCWNvdXQgPDwgYltpXVtqXSA8PCAiICI7CgkJfQoJCWNvdXQgPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9