Iterate over every cell
for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if ( visited [ i ] [ j ] == False and matrix [ i ] [ j ] == 1 ) : NEW_LINE INDENT COUNT = 0 NEW_LINE DEDENT DEDENT DEDENT