How sol matrix got updated with correct path

when we back track we assigned soln[i][j]==0; and if rightsucces||downsuccess is one it goes to back case and give sol[m][n]==1; but while pritning it printed sol[i][j]=1 for rightsucces||downsuccess 1 ,why ?please explain

hi @mvarun975_a7021058d653891d u print in the base case till there u are not going back once u print it then u start going back