#define U if((t+2)%(A[k][l]+1))d[k][l]=1 ll@H,@W,@--T,@--S,@--s,@--G,@--g,A[H][W],k,l;rep(i,H)rep(j,W){char@a;A[i][j]=a-48;}VVI D(H,VI(W));D[S][s]=1;REP(t,T){VVI d(H,VI(W));rep(i,H)rep(j,W)if(D[i][j]){k=i,l=j;U;if(i){k--;U;}if(i+1