include[HTML_REMOVED]
using namespace std;
int res[100][100],n,m,dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int main(){
scanf(“%d%d”,&n,&m);
for(int x=0,y=0,d=0,k=1;k<=n*m;k){
res[x][y]=k;
int a=x+dx[d],b=y+dy[d];
if(a<0||a>=n||b>=m||b<0||res[a][b]){
d=(d+1)%4;
a=x+dx[d],b=y+dy[d];
}
x=a,y=b;
}
for(int i=0;i<n;i){
for(int j=0;j<m;j++)
printf(“%4d”,res[i][j]);
printf(“\n”);
}
return 0;
}