






"""simple docstring"""




from __future__ import annotations






def 							lowerCAmelCase			(   UpperCamelCase_:				List[Any]  ,			UpperCamelCase_:				int       )							->				Union[str, Any]:







  '''simple docstring'''







  _a					      =						"", "", ""
  _a					      =						[]

  for character in message_part:
    tmp.append(character_to_number[character]       )

  for each in tmp:
    one += each[0]
    two += each[1]
    three += each[2]

  return one + two + three






def 							lowerCAmelCase			(   UpperCamelCase_:				Optional[Any]  ,			UpperCamelCase_:				Optional[Any]       )							->				Tuple:







  '''simple docstring'''







  _a					      =						"", ""
  _a					      =						[]

  for character in message_part:
    this_part += character_to_number[character]

  for digit in this_part:
    tmp += digit
    if len(snake_case__       ) == len(snake_case__       ):
      result.append(snake_case__       )
      _a					      =						""

  return result[0], result[1], result[2]






def 							lowerCAmelCase			(   UpperCamelCase_:				Dict  ,			UpperCamelCase_:				str       )							->				Any:







  '''simple docstring'''







  _a					      =						alphabet.replace(" "  ,			""       ).upper()
  _a					      =						message.replace(" "  ,			""       ).upper()

  # Check length and characters
  if len(snake_case__       ) != 27:
    raise KeyError("Length of alphabet has to be 27."       )
  for each in message:
    if each not in alphabet:
      raise ValueError("Each message character has to be included in alphabet!"       )

    # Generate dictionares
  _a					      =						(
      "111",
      "112",
      "113",
      "121",
      "122",
      "123",
      "131",
      "132",
      "133",
      "211",
      "212",
      "213",
      "221",
      "222",
      "223",
      "231",
      "232",
      "233",
      "311",
      "312",
      "313",
      "321",
      "322",
      "323",
      "331",
      "332",
      "333",
  )
  _a					      =						{}
  _a					      =						{}
  for letter, number in zip(snake_case__  ,			snake_case__       ):
    _a					      =						number
    _a					      =						letter

  return message, alphabet, character_to_number, number_to_character






def 							lowerCAmelCase			(   UpperCamelCase_:				Dict  ,			UpperCamelCase_:				str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ."  ,			UpperCamelCase_:				Any = 5       )							->				Union[str, Any]:







  '''simple docstring'''







  _a					      =						__prepare(
      snake_case__  ,			snake_case__       )
  _a					      =						"", ""

  for i in range(0  ,			len(snake_case__       ) + 1  ,			snake_case__       ):
    encrypted_numeric += __encrypt_part(
        message[i : i + period]  ,			snake_case__       )

  for i in range(0  ,			len(snake_case__       )  ,			3       ):
    encrypted += number_to_character[encrypted_numeric[i : i + 3]]

  return encrypted






def 							lowerCAmelCase			(   UpperCamelCase_:				Optional[Any]  ,			UpperCamelCase_:				Union[str, Any] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ."  ,			UpperCamelCase_:				List[Any] = 5       )							->				Dict:







  '''simple docstring'''







  _a					      =						__prepare(
      snake_case__  ,			snake_case__       )
  _a					      =						[]
  _a					      =						""

  for i in range(0  ,			len(snake_case__       ) + 1  ,			snake_case__       ):
    _a					      =						__decrypt_part(message[i : i + period]  ,			snake_case__       )

    for j in range(0  ,			len(snake_case__       )       ):
      decrypted_numeric.append(a[j] + b[j] + c[j]       )

  for each in decrypted_numeric:
    decrypted += number_to_character[each]

  return decrypted


if __name__ == "__main__":
     UpperCamelCase											=     """DEFEND THE EAST WALL OF THE CASTLE."""
     UpperCamelCase											=     encrypt_message(msg, """EPSDUCVWYM.ZLKXNBTFGORIJHAQ""")
     UpperCamelCase											=     decrypt_message(encrypted, """EPSDUCVWYM.ZLKXNBTFGORIJHAQ""")
     print(f"Encrypted: {encrypted}\nDecrypted: {decrypted}")








'''simple docstring'''






import itertools

def      __lowerCAmelCase   (       snake_case__		):
			return (
			    int("".join(combination[0:2]		)		) * int("".join(combination[2:5]		)		)
			    == int("".join(combination[5:9]		)		)
			) or (
			    int("".join(combination[0]		)		) * int("".join(combination[1:5]		)		)
			    == int("".join(combination[5:9]		)		)
			)

def      __lowerCAmelCase   (       ):
			return sum(
			    {
			        int("".join(pandigital[5:9]		)		)
			        for pandigital in itertools.permutations("123456789"		)
			        if is_combination_valid(snake_case__		)
			    }		)


if __name__ == "__main__":
				print(solution())



