


from __future__ import annotations

from collections import deque







class lowerCAmelCase_						:

 '''simple docstring'''

 def __init__(     self		,				_UpperCAmelCase ):
       snake_case_	=				[]
       self.adlist.append(
           {'''value''': '''''', '''next_states''': [], '''fail_state''': 0, '''output''': []} )

       for keyword in keywords:
             self.add_keyword(_UpperCAmelCase )
       self.set_fail_transitions()



 def 						UpperCamelCase__					(     self		,				_UpperCAmelCase		,				_UpperCAmelCase ):
       for state in self.adlist[current_state]["next_states"]:
             if char == self.adlist[state]["value"]:
                   return state
       return None



 def 						UpperCamelCase__					(     self		,				_UpperCAmelCase ):
       snake_case_	=				0
       for character in keyword:
             snake_case_	=				self.find_next_state(_UpperCAmelCase		,				_UpperCAmelCase )
             if next_state is None:
                   self.adlist.append(
                       {
                           '''value''': character,
                           '''next_states''': [],
                           '''fail_state''': 0,
                           '''output''': [],
                       } )
                   self.adlist[current_state]["next_states"].append(len(self.adlist ) - 1 )
                   snake_case_	=				len(self.adlist ) - 1
             else:
                   snake_case_	=				next_state
       self.adlist[current_state]["output"].append(_UpperCAmelCase )



 def 						UpperCamelCase__					(     self ):
       snake_case_	=				deque()
       for node in self.adlist[0]["next_states"]:
             q.append(_UpperCAmelCase )
             snake_case_	=				0
       while q:
             snake_case_	=				q.popleft()
             for child in self.adlist[r]["next_states"]:
                   q.append(_UpperCAmelCase )
                   snake_case_	=				self.adlist[r]['''fail_state''']
                   while (
                       self.find_next_state(_UpperCAmelCase		,				self.adlist[child]['''value'''] ) is None
                       and state != 0
                   ):
                         snake_case_	=				self.adlist[state]['''fail_state''']
                   snake_case_	=				self.find_next_state(
                       _UpperCAmelCase		,				self.adlist[child]['''value'''] )
                   if self.adlist[child]["fail_state"] is None:
                         snake_case_	=				0
                   snake_case_	=				(
                       self.adlist[child]['''output''']
                       + self.adlist[self.adlist[child]['''fail_state''']]['''output''']
                   )





 def 						UpperCamelCase__					(     self		,				_UpperCAmelCase ):
       snake_case_	=				{}  # returns a dict with keywords and list of its occurrences
       snake_case_	=				0
       for i in range(len(_UpperCAmelCase ) ):
             while (
                 self.find_next_state(_UpperCAmelCase		,				string[i] ) is None
                 and current_state != 0
             ):
                   snake_case_	=				self.adlist[current_state]['''fail_state''']
             snake_case_	=				self.find_next_state(_UpperCAmelCase		,				string[i] )
             if next_state is None:
                   snake_case_	=				0
             else:
                   snake_case_	=				next_state
                   for key in self.adlist[current_state]["output"]:
                         if key not in result:
                               snake_case_	=				[]
                         result[key].append(i - len(_UpperCAmelCase ) + 1 )
       return result


if __name__ == "__main__":
   import doctest

   doctest.testmod()



def 	__lowerCAmelCase   (SCREAMING_SNAKE_CASE )->  int:




      """simple docstring"""

      if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ):
            snake_case_	=				f'''Input value of [number={number}] must be an integer'''
            raise TypeError(SCREAMING_SNAKE_CASE )

      if number < 1:
            snake_case_	=				f'''Input value of [number={number}] must be > 0'''
            raise ValueError(SCREAMING_SNAKE_CASE )

      snake_case_	=				1

      for i in range(1 , SCREAMING_SNAKE_CASE ):
            current_number *= 4 * i - 2
            current_number //= i + 1

      return current_number


if __name__ == "__main__":
   import doctest

   doctest.testmod()