Stores if a position in the matrix been visited or not
vis = new List < List < bool > > ( ) ; for ( int i = 0 ; i < M + 5 ; i ++ ) { vis . Add ( new List < bool > ( ) ) ; for ( int j = 0 ; j < N + 5 ; j ++ ) { vis [ i ] . Add ( false ) ; } }