// duyet mang hinh tron oc
#include<iostream>
using namespace std;
int main() {
freopen("TronOc.txt", "r", stdin);
int N, M;
cin >> N >> M;
int a[N][M];
for(int i = 0; i<N; i++){
for(int j = 0; j <M; j++){
cin >> a[i][j];
}
}
for(int i = 0; i<N-i; i++){
// cout << i << " " << endl;
for(int j = i; j <M-i; j++){
if(j==M-i-1 ){
// cout <<endl<< i << " " << j << endl;
int k = i, p = j;
if(k==N-i-1) cout<<a[i][j] << " ";
while(k<N-i-1){
// cout <<endl<< k << " " << p << endl;
cout<< a[k][j] << " ";
k++;
}
while(p>i){
// cout <<endl<< k << " " << p << endl;
cout<< a[k][p] << " ";
p--;
}
while(k>i){
// cout <<endl<< k << " " << p << endl;
cout<< a[k][p] << " ";
k--;
}
}
else{
// cout <<endl<< i << " " << j << endl;
cout<<a[i][j] << " ";
}
}
cout<<endl;
}
}
//4 4
// 1 2 3 4
//12 13 14 5
//11 16 15 6
//10 9 8 7
//7 7
// 1 2 3 4 5 6 7
//24 25 26 27 28 29 8
//23 40 41 42 43 30 9
//22 39 48 49 44 31 10
//21 38 47 46 45 32 11
//20 37 36 35 34 33 12
//19 18 17 16 15 14 13
//4 5
// 1 2 3 4 5
//14 15 16 17 6
//13 20 19 18 7
//12 11 10 9 8
// thieu 8, 12
//6 5
// 1 2 3 4 5
//20 21 22 23 6
//19 30 31 24 7
//18 29 32 25 9
//17 28 27 26 10
//16 15 14 13 11