#include using namespace std; const int inf = 9999; char m0[52][52]; char m1[52][52]; int d1[52][52]; int r,c; int dt[52][52]; void debug_m0() { for(int i=0; i find_removeable(int li, int lj) { for(int i=0; i > q; q.push({li,lj}); while(!q.empty()){ int i = q.front()[0]; int j = q.front()[1]; li=i; lj=j; q.pop(); if(i&&dt[i-1][j]>dt[i][j]+1) { dt[i-1][j]=dt[i][j]+1; q.push({i-1,j}); } if(i+1dt[i][j]+1) { dt[i+1][j]=dt[i][j]+1; q.push({i+1,j}); } if(j&&dt[i][j-1]>dt[i][j]+1) { dt[i][j-1]=dt[i][j]+1; q.push({i,j-1}); } if(j+1dt[i][j]+1) { dt[i][j+1]=dt[i][j]+1; q.push({i,j+1}); } } return {li,lj}; } array find_next(int li, int lj) { for(int i=0; i > q; q.push({li,lj}); while(!q.empty()){ int i = q.front()[0]; int j = q.front()[1]; q.pop(); if(i&&dt[i-1][j]>dt[i][j]+1) { dt[i-1][j]=dt[i][j]+1; q.push({i-1,j}); } if(i+1dt[i][j]+1) { dt[i+1][j]=dt[i][j]+1; q.push({i+1,j}); } if(j&&dt[i][j-1]>dt[i][j]+1) { dt[i][j-1]=dt[i][j]+1; q.push({i,j-1}); } if(j+1dt[i][j]+1) { dt[i][j+1]=dt[i][j]+1; q.push({i,j+1}); } } for(int i=0; i ans = {-1,-1}; for(int i=0; i>r>>c; for(int i=0; i>s; for(int j=0; j>s; for(int j=0; j > q; for(int i=0; id1[i][j]+1) { d1[i-1][j]=d1[i][j]+1; q.push({i-1,j}); } if(i+1d1[i][j]+1) { d1[i+1][j]=d1[i][j]+1; q.push({i+1,j}); } if(j&&d1[i][j-1]>d1[i][j]+1) { d1[i][j-1]=d1[i][j]+1; q.push({i,j-1}); } if(j+1d1[i][j]+1) { d1[i][j+1]=d1[i][j]+1; q.push({i,j+1}); } } for(int i=0; i > ans; //debug_m0(); while(1) { auto [ri,rj] = find_removeable(li,lj); if(over()) break; m0[ri][rj]='.'; //debug_m0(); auto [ai,aj] = find_next(li,lj); m0[ai][aj]='*'; //debug_m0(); ans.push_back({ri,rj,ai,aj}); li=ai; lj=aj; } cout<<"YES\n"; cout<