


'''simple docstring'''






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


def       _snake_case     (  A				,					A )		->					Generator[tuple[str, ...], None, None]:
							lowerCAmelCase__      =			iter(A )
							while True:
														lowerCAmelCase__      =			tuple(itertools.islice(A				,					A ) )
														if not chunk:
																					return
														yield chunk


def       _snake_case     (  A )		->					str:
							lowerCAmelCase__      =			''''''.join([c.upper() for c in dirty if c in string.ascii_letters] )
							lowerCAmelCase__      =			''''''

							if len(A ) < 2:
														return dirty

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

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

							clean += dirty[-1]

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

							return clean


def       _snake_case     (  A )		->					list[str]:
							# I and J are used interchangeably to allow
							# us to use a 5x5 table (25 letters)
							lowerCAmelCase__      =			'''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
							lowerCAmelCase__      =			[]

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

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

							return table


def       _snake_case     (  A				,					A )		->					str:
							lowerCAmelCase__      =			generate_table(A )
							lowerCAmelCase__      =			prepare_input(A )
							lowerCAmelCase__      =			''''''

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

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



'''simple docstring'''






def       _snake_case     (  A				,					A )		->					bool:
							lowerCAmelCase__      =			len(A ) + 1
							lowerCAmelCase__      =			len(A ) + 1

							# dp is a 2d matrix where dp[i][j] denotes whether prefix string of
							# length i of input_string matches with prefix string of length j of
							# given pattern.
							# "dp" stands for dynamic programming.
							lowerCAmelCase__      =			[[0 for i in range(A )] for j in range(A )]

							# since string of zero length match pattern of zero length
							lowerCAmelCase__      =			1

							# since pattern of zero length will never match with string of non-zero length
							for i in range(1				,					A ):
														lowerCAmelCase__      =			0

							# since string of zero length will match with pattern where there
							# is at least one * alternatively
							for j in range(1				,					A ):
														lowerCAmelCase__      =			dp[0][j - 2] if pattern[j - 1] == '''*''' else 0

							# now using bottom-up approach to find for all remaining lengths
							for i in range(1				,					A ):
														for j in range(1				,					A ):
																					if input_string[i - 1] == pattern[j - 1] or pattern[j - 1] == ".":
																												lowerCAmelCase__      =			dp[i - 1][j - 1]

																					elif pattern[j - 1] == "*":
																												if dp[i][j - 2] == 1:
																																			lowerCAmelCase__      =			1
																												elif pattern[j - 2] in (input_string[i - 1], "."):
																																			lowerCAmelCase__      =			dp[i - 1][j]
																												else:
																																			lowerCAmelCase__      =			0
																					else:
																												lowerCAmelCase__      =			0

							return bool(dp[-1][-1] )


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		# inputing the strings
		# input_string = input("input a string :")
		# pattern = input("input a pattern :")

		__UpperCAmelCase					       =							'''aab'''
		__UpperCAmelCase					       =							'''c*a*b'''

		# using function to check whether given string matches the given pattern
		if match_pattern(input_string, pattern):
				print(f"""{input_string} matches the given pattern {pattern}""")
		else:
				print(f"""{input_string} does not match with the given pattern {pattern}""")