


class 							A   :
					'''simple docstring'''






					def __init__(self   :						Union[str, Any]				, _UpperCAmelCase   :						List[str]		)						->       Union[str, Any]:




							"""simple docstring"""


							lowercase__					      =		n
							lowercase__					      =		[None] * self.n
							lowercase__					      =		0  # index of the first element
							lowercase__					      =		0
							lowercase__					      =		0

					def __len__(self   :						Any		)						->       int:




							"""simple docstring"""


							return self.size

					def   lowerCamelCase__					(self   :						str		)						->       bool:




							"""simple docstring"""


							return self.size == 0

					def   lowerCamelCase__					(self   :						Optional[Any]		)						->       Tuple:




							"""simple docstring"""


							return False if self.is_empty() else self.array[self.front]

					def   lowerCamelCase__					(self   :						List[Any]				, _UpperCAmelCase   :						Any		)						->       Dict:




							"""simple docstring"""


							if self.size >= self.n:
									raise Exception("""QUEUE IS FULL"""		)

							lowercase__					      =		data
							lowercase__					      =		(self.rear + 1) % self.n
							self.size += 1
							return self


					def   lowerCamelCase__					(self   :						Tuple		)						->       Optional[int]:




							"""simple docstring"""


							if self.size == 0:
									raise Exception("""UNDERFLOW"""		)

							lowercase__					      =		self.array[self.front]
							lowercase__					      =		None
							lowercase__					      =		(self.front + 1) % self.n
							self.size -= 1
							return temp









class 							A   :
					'''simple docstring'''






					def __init__(self   :						int				, _UpperCAmelCase   :						list		)						->       None:




							"""simple docstring"""


							lowercase__					      =		set_counts
							lowercase__					      =		max(_UpperCAmelCase		)
							lowercase__					      =		len(_UpperCAmelCase		)
							lowercase__					      =		[1] * num_sets
							lowercase__					      =		list(range(_UpperCAmelCase		)		)

					def   lowerCamelCase__					(self   :						List[Any]				, _UpperCAmelCase   :						int				, _UpperCAmelCase   :						int		)						->       bool:




							"""simple docstring"""


							lowercase__					      =		self.get_parent(_UpperCAmelCase		)
							lowercase__					      =		self.get_parent(_UpperCAmelCase		)

							if src_parent == dst_parent:
									return False

							if self.ranks[dst_parent] >= self.ranks[src_parent]:
									self.set_counts[dst_parent] += self.set_counts[src_parent]
									lowercase__					      =		0
									lowercase__					      =		dst_parent
									if self.ranks[dst_parent] == self.ranks[src_parent]:
											self.ranks[dst_parent] += 1
									lowercase__					      =		self.set_counts[dst_parent]
							else:
									self.set_counts[src_parent] += self.set_counts[dst_parent]
									lowercase__					      =		0
									lowercase__					      =		src_parent
									lowercase__					      =		self.set_counts[src_parent]

							lowercase__					      =		max(self.max_set				, _UpperCAmelCase		)
							return True


					def   lowerCamelCase__					(self   :						List[Any]				, _UpperCAmelCase   :						int		)						->       int:




							"""simple docstring"""


							if self.parents[disj_set] == disj_set:
									return disj_set
							lowercase__					      =		self.get_parent(self.parents[disj_set]		)
							return self.parents[disj_set]

