#include<iostream>
using namespace std;
int A[21][21],n,m;
void readMatrix(){
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>A[i][j];
}
void interchange(){
for(int j=1;j<=m;j++){
int aux=A[1][j];
A[1][j]=A[2][j];
A[2][j]=aux;
}
}
void writeMatrix(){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
cout<<A[i][j]<<' ';
cout<<endl;
}
}
int main(){
readMatrix();
interchange();
writeMatrix();
return 0;
}