#include
using namespace std;
void spirlprint(int a[][100],int n, int m){
int sr=0, sc=0, er=n-1, ec=m-1;
while(sr<=er and sc<=ec){
for(int col=sc; col<=ec; col++){
cout<<a[sr][col]<<", “;
}
sr++;
for(int row=sr; row<=er; row++){
cout<<a[row][ec]<<”, “;
}
ec–;
for(int col=ec; col>=sc; col–){
cout<<a[er][col]<<”, “;
}
er–;
for(int row=er; row>=sr; row–){
cout<<a[row][sc]<<”, ";
}
sc++;
}
cout<<“END”<<endl;
}
int main() {
int a[100][100];
int val=1;
int r,c;
cin>>r;
cin>>c;
for(int i=0; i<r; i++){
for(int j=0; j<c; j++){
a[i][j]=val;
val++;
}
}
spirlprint(a,r,c);
return 0;
}