#include
using namespace std;
void sp(int a[100][100],int r,int c){
int sr=0,sc=0,er=r-1,ec=c-1;
while(sr<=er && sc<=ec){
for(int i=sc;i<=ec;i++){
cout<<a[sr][i]<<","<<" “;
}
sr++;
for(int j=sr;j<=er;j++){
cout<<a[j][ec]<<”,"<<" ";
}
ec--;
for(int x=ec;x>=sc;x--){
cout<<a[er][x]<<","<<" ";
}
er--;
if(sr<er){
for(int y=er;y>=sr;y--){
cout<<a[y][sc]<<","<<" ";
}
sc++;
}
}
cout<<"END";
}
int main() {
int r,c;cin>>r>>c;int a[100][100];
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
cin>>a[i][j];
}
}
sp(a,r,c);
return 0;
}