
from __future__ import annotations


def 				A	( lowercase   ,	lowercase = None			)       ->  list[list[str]]:
		'''simple docstring'''

		UpperCamelCase          =					word_bank or []
		# create a table
		UpperCamelCase          =					len(lowercase			) + 1

		UpperCamelCase          =					[]
		for _ in range(lowercase			):
				table.append([]			)
		# seed value
		UpperCamelCase          =					[[]]  # because empty string has empty combination

		# iterate through the indices
		for i in range(lowercase			):
				# condition
				if table[i] != []:
						for word in word_bank:
								# slice condition
								if target[i : i + len(lowercase			)] == word:
										UpperCamelCase          =					[
										    [word, *way] for way in table[i]
										]
										# adds the word to every combination the current position holds
										# now,push that combination to the table[i+len(word)]
										table[i + len(lowercase			)] += new_combinations

    # combinations are in reverse order so reverse for better output
		for combination in table[len(lowercase			)]:
				combination.reverse()

		return table[len(lowercase			)]


if __name__ == "__main__":
					print(all_construct("jwajalapa", ["jwa", "j", "w", "a", "la", "lapa"]))
					print(all_construct("rajamati", ["s", "raj", "amat", "raja", "ma", "i", "t"]))
					print(
					    all_construct(
					        "hexagonosaurus",
					        ["h", "ex", "hex", "ag", "ago", "ru", "auru", "rus", "go", "no", "o", "s"],
					    )
					)


from __future__ import annotations


def 				A	( lowercase   ,	lowercase			)       ->  tuple[int, int]:
		'''simple docstring'''

		if b == 0:
				return (1, 0)
		((UpperCamelCase)     ,  (UpperCamelCase))          =					extended_euclid(lowercase   ,	a % b			)
		UpperCamelCase          =					a // b
		return (y, x - k * y)


def 				A	( lowercase   ,	lowercase   ,	lowercase   ,	lowercase			)       ->  int:
		'''simple docstring'''

		((UpperCamelCase)     ,  (UpperCamelCase))          =					extended_euclid(lowercase   ,	lowercase			)
		UpperCamelCase          =					na * na
		UpperCamelCase          =					ra * x * na + ra * y * na
		return (n % m + m) % m


def 				A	( lowercase   ,	lowercase			)       ->  int:
		'''simple docstring'''

		((UpperCamelCase)     ,  (UpperCamelCase))          =					extended_euclid(lowercase   ,	lowercase			)
		if b < 0:
				UpperCamelCase          =					(b % n + n) % n
		return b


def 				A	( lowercase   ,	lowercase   ,	lowercase   ,	lowercase			)       ->  int:
		'''simple docstring'''

		UpperCamelCase     ,  UpperCamelCase          =					invert_modulo(lowercase   ,	lowercase			), invert_modulo(lowercase   ,	lowercase			)
		UpperCamelCase          =					na * na
		UpperCamelCase          =					ra * x * na + ra * y * na
		return (n % m + m) % m


if __name__ == "__main__":
					from doctest import testmod

					testmod(name="chinese_remainder_theorem", verbose=True)
					testmod(name="chinese_remainder_theorem2", verbose=True)
					testmod(name="invert_modulo", verbose=True)
					testmod(name="extended_euclid", verbose=True)
