If the current cell is valid cell and can be traversed
if ( isValid ( row , col ) and ( mat [ row ] [ col ] == '1' or mat [ row ] [ col ] == ' s ' or mat [ row ] [ col ] == ' d ' ) and ( not visited [ row ] [ col ] ) ) : NEW_LINE