Recur for all connected neighbours
for k in range ( 8 ) : NEW_LINE INDENT if ( isvalid ( row + rowNum [ k ] , col + colNum [ k ] , prevRow , prevCol ) ) : NEW_LINE INDENT DFS ( mat , row + rowNum [ k ] , col + colNum [ k ] , row , col , word , path , index + 1 , n ) NEW_LINE DEDENT DEDENT