#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int ara[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cin >> ara[i][j];
}
}
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
int temp;
temp = ara[i][j];
ara[i][j] = ara[j][i];
ara[j][i] = temp;
cout << ara[i][j] << " ";
}
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbiwgbTsKCWNpbiA+PiBuID4+IG07CglpbnQgYXJhW25dW21dOwoJCglmb3IoaW50IGk9MDsgaTxuOyBpKyspewoJCWZvcihpbnQgaj0wOyBqPG07IGorKyl7CgkJCWNpbiA+PiBhcmFbaV1bal07CgkJfQoJfQoJCglmb3IoaW50IGk9MDsgaTxuOyBpKyspewoJCWZvcihpbnQgaj0wOyBqPG07IGorKyl7CgkJCWludCB0ZW1wOwoJCQl0ZW1wID0gYXJhW2ldW2pdOwoJCQlhcmFbaV1bal0gPSBhcmFbal1baV07CgkJCWFyYVtqXVtpXSA9IHRlbXA7CgkJCQoJCQljb3V0IDw8IGFyYVtpXVtqXSA8PCAiICI7CgkJfQoJCWNvdXQgPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9