






class 				__A     :





				"""simple docstring"""







				def __init__( self							,  lowerCamelCase__    ):




									"""simple docstring"""

									__UpperCamelCase      :					str       		=set_counts
									__UpperCamelCase      :					Optional[Any]       		=max(lowerCamelCase__    )
									__UpperCamelCase      :					Dict       		=len(lowerCamelCase__    )
									__UpperCamelCase      :					Optional[Any]       		=[1] * num_sets
									__UpperCamelCase      :					Optional[Any]       		=list(range(lowerCamelCase__    )    )


				def       __lowercase							( self							,  lowerCamelCase__							,  lowerCamelCase__    ):




									"""simple docstring"""

									__UpperCamelCase      :					List[Any]       		=self.get_parent(lowerCamelCase__    )
									__UpperCamelCase      :					List[str]       		=self.get_parent(lowerCamelCase__    )

									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]
														__UpperCamelCase      :					int       		=0
														__UpperCamelCase      :					Any       		=dst_parent
														if self.ranks[dst_parent] == self.ranks[src_parent]:
																			self.ranks[dst_parent] += 1
														__UpperCamelCase      :					List[str]       		=self.set_counts[dst_parent]
									else:
														self.set_counts[src_parent] += self.set_counts[dst_parent]
														__UpperCamelCase      :					List[Any]       		=0
														__UpperCamelCase      :					int       		=src_parent
														__UpperCamelCase      :					int       		=self.set_counts[src_parent]

									__UpperCamelCase      :					Tuple       		=max(self.max_set							,  lowerCamelCase__    )
									return True







				def       __lowercase							( self							,  lowerCamelCase__    ):




									"""simple docstring"""

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


import itertools
import string
from collections.abc import Generator, Iterable
def       A	(    _lowercase		,  _lowercase						):
						SCREAMING_SNAKE_CASE							:    Union[str, Any]							=							iter(_lowercase						)
						while True:
												SCREAMING_SNAKE_CASE							:    Optional[Any]							=							tuple(itertools.islice(_lowercase		,  _lowercase						)						)
												if not chunk:
																		return
												yield chunk
def       A	(    _lowercase						):
						SCREAMING_SNAKE_CASE							:    int							=							''''''.join([c.upper() for c in dirty if c in string.ascii_letters]						)
						SCREAMING_SNAKE_CASE							:    List[str]							=							''''''

						if len(_lowercase						) < 2:
												return dirty

						for i in range(len(_lowercase						) - 1						):
												clean += dirty[i]

												if dirty[i] == dirty[i + 1]:
																		clean += "X"

						clean += dirty[-1]

						if len(_lowercase						) & 1:
												clean += "X"

						return clean
def       A	(    _lowercase						):
						# I and J are used interchangeably to allow
						# us to use a 5x5 table (25 letters)
						SCREAMING_SNAKE_CASE							:    Optional[Any]							=							'''ABCDEFGHIKLMNOPQRSTUVWXYZ'''
						# we're using a list instead of a '2d' array because it makes the math
						# for setting up the table and doing the actual encoding/decoding simpler
						SCREAMING_SNAKE_CASE							:    List[Any]							=							[]

						# copy key chars into the table if they are in `alphabet` ignoring duplicates
						for char in key.upper():
												if char not in table and char in alphabet:
																		table.append(_lowercase						)

    # fill the rest of the table in with the remaining alphabet chars
						for char in alphabet:
												if char not in table:
																		table.append(_lowercase						)

						return table
def       A	(    _lowercase		,  _lowercase						):
						SCREAMING_SNAKE_CASE							:    Any							=							generate_table(_lowercase						)
						SCREAMING_SNAKE_CASE							:    Any							=							prepare_input(_lowercase						)
						SCREAMING_SNAKE_CASE							:    Union[str, Any]							=							''''''

						# https://en.wikipedia.org/wiki/Playfair_cipher#Description
						for chara, chara in chunker(_lowercase		,  2						):
												SCREAMING_SNAKE_CASE				,  SCREAMING_SNAKE_CASE							:    int							=							divmod(table.index(_lowercase						)		,  5						)
												SCREAMING_SNAKE_CASE				,  SCREAMING_SNAKE_CASE							:    Union[str, Any]							=							divmod(table.index(_lowercase						)		,  5						)

												if rowa == rowa:
																		ciphertext += table[rowa * 5 + (cola + 1) % 5]
																		ciphertext += table[rowa * 5 + (cola + 1) % 5]
												elif cola == cola:
																		ciphertext += table[((rowa + 1) % 5) * 5 + cola]
																		ciphertext += table[((rowa + 1) % 5) * 5 + cola]
												else:  # rectangle
																		ciphertext += table[rowa * 5 + cola]
																		ciphertext += table[rowa * 5 + cola]

						return ciphertext



def       A	(    _lowercase		,  _lowercase						):
						SCREAMING_SNAKE_CASE							:    Any							=							generate_table(_lowercase						)
						SCREAMING_SNAKE_CASE							:    List[Any]							=							''''''

						# https://en.wikipedia.org/wiki/Playfair_cipher#Description
						for chara, chara in chunker(_lowercase		,  2						):
												SCREAMING_SNAKE_CASE				,  SCREAMING_SNAKE_CASE							:    List[str]							=							divmod(table.index(_lowercase						)		,  5						)
												SCREAMING_SNAKE_CASE				,  SCREAMING_SNAKE_CASE							:    Optional[Any]							=							divmod(table.index(_lowercase						)		,  5						)

												if rowa == rowa:
																		plaintext += table[rowa * 5 + (cola - 1) % 5]
																		plaintext += table[rowa * 5 + (cola - 1) % 5]
												elif cola == cola:
																		plaintext += table[((rowa - 1) % 5) * 5 + cola]
																		plaintext += table[((rowa - 1) % 5) * 5 + cola]
												else:  # rectangle
																		plaintext += table[rowa * 5 + cola]
																		plaintext += table[rowa * 5 + cola]

						return plaintext





