#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int rows,cols; cin>>rows>>cols;
	vector<vector<int>>arr(rows,vector<int>(cols));
	for(int i =0;i<rows;i++){
		for(int j =0;j<cols;j++){
			cin>>arr[i][j];
		}
	}
	for(int i =0;i<rows;i++){
		for(int j =0;j<cols;j++){
			if(i<j)	swap(arr[i][j],arr[j][i]);
		}
	}
	for(int i =0;i<rows;i++){
		for(int j =0;j<cols;j++){
			cout<<arr[i][j];
		}
		cout<<endl;
	}
	
	
	return 0;
}