



from collections import namedtuple

lowerCamelCase__			= namedtuple("""from_to""", """from_ to""")

lowerCamelCase__			= {
    """cubicmeter""": from_to(1, 1),
    """litre""": from_to(0.001, 1000),
    """kilolitre""": from_to(1, 1),
    """gallon""": from_to(0.0_0454, 264.172),
    """cubicyard""": from_to(0.7_6455, 1.3_0795),
    """cubicfoot""": from_to(0.028, 35.3147),
    """cup""": from_to(0.0_0023_6588, 4226.75),
}

def   lowerCAmelCase__						(							_SCREAMING_SNAKE_CASE       :			float				,     _SCREAMING_SNAKE_CASE       :			str				,     _SCREAMING_SNAKE_CASE       :			str    ):
				"""simple docstring"""







				if from_type not in METRIC_CONVERSION:
								raise ValueError(
								    f"Invalid 'from_type' value: {from_type!r}  Supported values are:\n"
								    + """, """.join(_SCREAMING_SNAKE_CASE    )    )
				if to_type not in METRIC_CONVERSION:
								raise ValueError(
								    f"Invalid 'to_type' value: {to_type!r}.  Supported values are:\n"
								    + """, """.join(_SCREAMING_SNAKE_CASE    )    )
				return value * METRIC_CONVERSION[from_type].from_ * METRIC_CONVERSION[to_type].to


if __name__ == "__main__":
						import doctest

						doctest.testmod()





import itertools
import string
from collections.abc import Generator, Iterable

def   lowerCAmelCase__						(							_SCREAMING_SNAKE_CASE       :			Iterable[str]				,     _SCREAMING_SNAKE_CASE       :			int    ):
				"""simple docstring"""







				__a       =		iter(_SCREAMING_SNAKE_CASE    )
				while True:
								__a       =		tuple(itertools.islice(_SCREAMING_SNAKE_CASE				,     _SCREAMING_SNAKE_CASE    )    )
								if not chunk:
												return
								yield chunk

def   lowerCAmelCase__						(							_SCREAMING_SNAKE_CASE       :			str    ):
				"""simple docstring"""







				__a       =		"""""".join([c.upper() for c in dirty if c in string.ascii_letters]    )
				__a       =		""""""

				if len(_SCREAMING_SNAKE_CASE    ) < 2:
								return dirty

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

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

				clean += dirty[-1]

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

				return clean

def   lowerCAmelCase__						(							_SCREAMING_SNAKE_CASE       :			str    ):
				"""simple docstring"""







				__a       =		"""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
				__a       =		[]

				# 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(_SCREAMING_SNAKE_CASE    )

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

				return table

def   lowerCAmelCase__						(							_SCREAMING_SNAKE_CASE       :			str				,     _SCREAMING_SNAKE_CASE       :			str    ):
				"""simple docstring"""







				__a       =		generate_table(_SCREAMING_SNAKE_CASE    )
				__a       =		prepare_input(_SCREAMING_SNAKE_CASE    )
				__a       =		""""""

				# https://en.wikipedia.org/wiki/Playfair_cipher#Description
				for chara, chara in chunker(_SCREAMING_SNAKE_CASE				,     2    ):
								__a     ,					__a       =		divmod(table.index(_SCREAMING_SNAKE_CASE    )				,     5    )
								__a     ,					__a       =		divmod(table.index(_SCREAMING_SNAKE_CASE    )				,     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   lowerCAmelCase__						(							_SCREAMING_SNAKE_CASE       :			str				,     _SCREAMING_SNAKE_CASE       :			str    ):
				"""simple docstring"""







				__a       =		generate_table(_SCREAMING_SNAKE_CASE    )
				__a       =		""""""

				# https://en.wikipedia.org/wiki/Playfair_cipher#Description
				for chara, chara in chunker(_SCREAMING_SNAKE_CASE				,     2    ):
								__a     ,					__a       =		divmod(table.index(_SCREAMING_SNAKE_CASE    )				,     5    )
								__a     ,					__a       =		divmod(table.index(_SCREAMING_SNAKE_CASE    )				,     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
