
"""simple docstring"""



from __future__ import annotations

from collections import deque

class       lowerCAmelCase__				:







     def __init__(							self			:			Union[str, Any]    ,      _lowerCamelCase			:			list[str]			):
       _snake_case					     =       []
       self.adlist.append(
           {'''value''': '''''', '''next_states''': [], '''fail_state''': 0, '''output''': []}			)

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







     def      lowercase	(							self			:			Tuple    ,      _lowerCamelCase			:			int    ,      _lowerCamelCase			:			str			):






       for state in self.adlist[current_state]["next_states"]:
         if char == self.adlist[state]["value"]:
           return state
       return None







     def      lowercase	(							self			:			Dict    ,      _lowerCamelCase			:			str			):
       _snake_case					     =       0
       for character in keyword:
         _snake_case					     =       self.find_next_state(lowerCAmelCase__    ,      lowerCAmelCase__			)
         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(lowerCAmelCase__			)







     def      lowercase	(							self			:			Optional[int]			):
       _snake_case					     =       deque()
       for node in self.adlist[0]["next_states"]:
         q.append(lowerCAmelCase__			)
         _snake_case					     =       0
       while q:
         _snake_case					     =       q.popleft()
         for child in self.adlist[r]["next_states"]:
           q.append(lowerCAmelCase__			)
           _snake_case					     =       self.adlist[r]["""fail_state"""]
           while (
               self.find_next_state(lowerCAmelCase__    ,      self.adlist[child]['''value''']			) is None
               and state != 0
           ):
             _snake_case					     =       self.adlist[state]["""fail_state"""]
           _snake_case					     =       self.find_next_state(
               lowerCAmelCase__    ,      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      lowercase	(							self			:			Tuple    ,      _lowerCamelCase			:			str			):
       _snake_case					     =       {}  # returns a dict with keywords and list of its occurrences
       _snake_case					     =       0
       for i in range(len(lowerCAmelCase__			)			):
         while (
             self.find_next_state(lowerCAmelCase__    ,      string[i]			) is None
             and current_state != 0
         ):
           _snake_case					     =       self.adlist[current_state]["""fail_state"""]
         _snake_case					     =       self.find_next_state(lowerCAmelCase__    ,      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(lowerCAmelCase__			) + 1			)
       return result


if __name__ == "__main__":
 import doctest

 doctest.testmod()








'''simple docstring'''




def 				lowerCAmelCase_   (	_lowerCamelCase:   int					):
		assert (
		    isinstance(_lowerCamelCase       ,      _lowerCamelCase					) and number_of_steps > 0
		), F"number_of_steps needs to be positive integer, your input {number_of_steps}"
		if number_of_steps == 1:
				return 1
		__SCREAMING_SNAKE_CASE       ,						__SCREAMING_SNAKE_CASE       :		Dict           =		1, 1
		for _ in range(number_of_steps - 1					):
				__SCREAMING_SNAKE_CASE       ,						__SCREAMING_SNAKE_CASE       :		Tuple           =		current + previous, current
		return current


if __name__ == "__main__":
						import doctest

						doctest.testmod()