Function to perform the DFS Traversal
void DFS ( vector < vector < int > > mat , int N , int M , int i , int j , vector < vector < bool > > & visited ) { if ( visited [ i ] [ j ] == true ) { return ; } visited [ i ] [ j ] = true ;