

'''simple docstring'''

class lowerCamelCase      :

				def __init__(					self   )						->       Any:
					# numbermap keys are the number and its values are lists of indexes sorted
					# in ascending order
					snake_case							 =				{}
					# indexmap keys are an index and it's values are the number at that index
					snake_case							 =				{}

				def 				_lowerCamelCase						(					self,	lowercase_,	lowercase_   )						->       Dict:
					if isinstance(__UpperCamelCase,	(range, str)   ):
						snake_case							 =				list(__UpperCamelCase   )
					elif not isinstance(__UpperCamelCase,	__UpperCamelCase   ):
						raise TypeError(
						    'binary_search_delete() only accepts either a list, range or str'   )

					snake_case							 =				0
					snake_case							 =				len(__UpperCamelCase   ) - 1

					while low <= high:
						snake_case							 =				(low + high) // 2
						if array[mid] == item:
							array.pop(__UpperCamelCase   )
							return array
						elif array[mid] < item:
							snake_case							 =				mid + 1
						else:
							snake_case							 =				mid - 1
					raise ValueError(
					    'Either the item is not in the array or the array was unsorted'   )

				def 				_lowerCamelCase						(					self,	lowercase_,	lowercase_   )						->       Union[str, Any]:
					if isinstance(__UpperCamelCase,	(range, str)   ):
						snake_case							 =				list(__UpperCamelCase   )
					elif not isinstance(__UpperCamelCase,	__UpperCamelCase   ):
						raise TypeError(
						    'binary_search_insert() only accepts either a list, range or str'   )

					snake_case							 =				0
					snake_case							 =				len(__UpperCamelCase   ) - 1

					while low <= high:
						snake_case							 =				(low + high) // 2
						if array[mid] == index:
							# If the item already exists in the array,
							# insert it after the existing item
							array.insert(mid + 1,	__UpperCamelCase   )
							return array
						elif array[mid] < index:
							snake_case							 =				mid + 1
						else:
							snake_case							 =				mid - 1

        # If the item doesn't exist in the array, insert it at the appropriate position
					array.insert(__UpperCamelCase,	__UpperCamelCase   )
					return array

				def 				_lowerCamelCase						(					self,	lowercase_,	lowercase_   )						->       Optional[Any]:
					# Remove previous index
					if index in self.indexmap:
						snake_case							 =				self.indexmap[index]
						if len(self.numbermap[n]   ) == 1:
							del self.numbermap[n]
						else:
							snake_case							 =				self.binary_search_delete(self.numbermap[n],	__UpperCamelCase   )

        # Set new index
					snake_case							 =				number

					# Number not seen before or empty so insert number value
					if number not in self.numbermap:
						snake_case							 =				[index]

					# Here we need to perform a binary search insertion in order to insert
					# The item in the correct place
					else:
						snake_case							 =				self.binary_search_insert(
						    self.numbermap[number],	__UpperCamelCase   )






				def 				_lowerCamelCase						(					self,	lowercase_   )						->       List[Any]:
					return self.numbermap.get(__UpperCamelCase,	[-1]   )[0]


if __name__ == "__main__":
						import doctest

						doctest.testmod()








'''simple docstring'''

lowerCAmelCase_						   =			{0: [1, 2], 1: [0, 3], 2: [0], 3: [1], 4: [5, 6], 5: [4, 6], 6: [4, 5]}

lowerCAmelCase_						   =			{0: [1, 2, 3], 1: [0, 3], 2: [0], 3: [0, 1], 4: [], 5: []}

def     __magic_name__       ( A					,   A					,   A							)			->		list:
	snake_case							 =				True
	snake_case							 =				[]

	for neighbour in graph[vert]:
		if not visited[neighbour]:
			connected_verts += dfs(A					,   A					,   A							)

	return [vert, *connected_verts]

def     __magic_name__       ( A							)			->		list:
	snake_case							 =				len(A							)
	snake_case							 =				graph_size * [False]
	snake_case							 =				[]

	for i in range(A							):
		if not visited[i]:
			snake_case							 =				dfs(A					,   A					,   A							)
			components_list.append(A							)

	return components_list


if __name__ == "__main__":
						import doctest

						doctest.testmod()





