


'''simple docstring'''




from typing import Any





def 	a_					( lowerCamelCase	:     List[str]	, lowerCamelCase	:     Tuple	, lowerCamelCase	:     Dict	, lowerCamelCase	:     str	, lowerCamelCase	:     Optional[int]	, ):
   _validation(
       _A	, _A	, _A	, _A	, _A	, )
   # Creates data structures and fill initial step
   lowerCAmelCase     =			{}
   lowerCAmelCase     =			{}
   for state in states_space:
      lowerCAmelCase     =			observations_space[0]
      lowerCAmelCase     =			(
          initial_probabilities[state] * emission_probabilities[state][observation]
      )
      lowerCAmelCase     =			None

   # Fills the data structure with the probabilities of
   # different transitions and pointers to previous states
   for o in range(1	, len(_A				)				):
      lowerCAmelCase     =			observations_space[o]
      lowerCAmelCase     =			observations_space[o - 1]
      for state in states_space:
         # Calculates the argmax for probability function
         lowerCAmelCase     =			''
         lowerCAmelCase     =			-1
         for k_state in states_space:
            lowerCAmelCase     =			(
                probabilities[(k_state, prior_observation)]
                * transition_probabilities[k_state][state]
                * emission_probabilities[state][observation]
            )
            if probability > max_probability:
               lowerCAmelCase     =			probability
               lowerCAmelCase     =			k_state

            # Update probabilities and pointers dicts
         lowerCAmelCase     =			(
             probabilities[(arg_max, prior_observation)]
             * transition_probabilities[arg_max][state]
             * emission_probabilities[state][observation]
         )

         lowerCAmelCase     =			arg_max

    # The final observation
   lowerCAmelCase     =			observations_space[len(_A				) - 1]

   # argmax for given final observation
   lowerCAmelCase     =			''
   lowerCAmelCase     =			-1
   for k_state in states_space:
      lowerCAmelCase     =			probabilities[(k_state, final_observation)]
      if probability > max_probability:
         lowerCAmelCase     =			probability
         lowerCAmelCase     =			k_state
   lowerCAmelCase     =			arg_max

   # Process pointers backwards
   lowerCAmelCase     =			last_state
   lowerCAmelCase     =			[]
   for o in range(len(_A				) - 1	, -1	, -1				):
      result.append(_A				)
      lowerCAmelCase     =			pointers[previous, observations_space[o]]
   result.reverse()

   return result





def 	a_					( lowerCamelCase	:     Dict	, lowerCamelCase	:     Tuple	, lowerCamelCase	:     Union[str, Any]	, lowerCamelCase	:     int	, lowerCamelCase	:     Any	, ):
   _validate_not_empty(
       _A	, _A	, _A	, _A	, _A	, )
   _validate_lists(_A	, _A				)
   _validate_dicts(
       _A	, _A	, _A				)





def 	a_					( lowerCamelCase	:     List[str]	, lowerCamelCase	:     List[Any]	, lowerCamelCase	:     Any	, lowerCamelCase	:     List[str]	, lowerCamelCase	:     Tuple	, ):





   if not all(
       [
           observations_space,
           states_space,
           initial_probabilities,
           transition_probabilities,
           emission_probabilities,
       ]				):
      raise ValueError('There\'s an empty parameter'				)





def 	a_					( lowerCamelCase	:     str	, lowerCamelCase	:     int				):
   _validate_list(_A	, 'observations_space'				)
   _validate_list(_A	, 'states_space'				)





def 	a_					( lowerCamelCase	:     Union[str, Any]	, lowerCamelCase	:     Optional[Any]				):





   if not isinstance(_object	, _A				):
      lowerCAmelCase     =			f'''{var_name} must be a list'''
      raise ValueError(_A				)
   else:
      for x in _object:
         if not isinstance(_A	, _A				):
            lowerCAmelCase     =			f'''{var_name} must be a list of strings'''
            raise ValueError(_A				)





def 	a_					( lowerCamelCase	:     List[str]	, lowerCamelCase	:     List[Any]	, lowerCamelCase	:     Any	, ):
   _validate_dict(_A	, 'initial_probabilities'	, _A				)
   _validate_nested_dict(_A	, 'transition_probabilities'				)
   _validate_nested_dict(_A	, 'emission_probabilities'				)





def 	a_					( lowerCamelCase	:     Any	, lowerCamelCase	:     Optional[int]				):
   _validate_dict(_object	, _A	, _A				)
   for x in _object.values():
      _validate_dict(_A	, _A	, _A	, _A				)





def 	a_					( lowerCamelCase	:     Union[str, Any]	, lowerCamelCase	:     str	, lowerCamelCase	:     Dict	, lowerCamelCase	:     Any = False				):





   if not isinstance(_object	, _A				):
      lowerCAmelCase     =			f'''{var_name} must be a dict'''
      raise ValueError(_A				)
   if not all(isinstance(_A	, _A				) for x in _object				):
      lowerCAmelCase     =			f'''{var_name} all keys must be strings'''
      raise ValueError(_A				)
   if not all(isinstance(_A	, _A				) for x in _object.values()				):
      lowerCAmelCase     =			'nested dictionary ' if nested else ''
      lowerCAmelCase     =			f'''{var_name} {nested_text}all values must be {value_type.__name__}'''
      raise ValueError(_A				)


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

       testmod()











def 						lowerCamelCase__    (		):







	'''simple docstring'''





	snake_case_		    =     []
	snake_case_		    =     1

	while len(_A							) < 1E6:
		constant.append(str(_A							)							)
		i += 1

	snake_case_		    =     "".join(_A							)

	return (
	    int(constant[0]							)
	    * int(constant[9]							)
	    * int(constant[99]							)
	    * int(constant[999]							)
	    * int(constant[9999]							)
	    * int(constant[99999]							)
	    * int(constant[999999]							)
	)


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