'''simple docstring'''




class        SCREAMING_SNAKE_CASE   :
  """simple docstring"""







  class        SCREAMING_SNAKE_CASE   :
    """simple docstring"""







    __A     =		"_prev", "_data", "_next"



    def __init__(  self   :					List[Any]					,					__lowerCAmelCase   :					Optional[Any]					,					__lowerCAmelCase   :					Tuple					,					__lowerCAmelCase   :					str					):


          """simple docstring"""



          _lowerCAmelCase		   =   link_p
          _lowerCAmelCase		   =   element
          _lowerCAmelCase		   =   link_n



    def   a   (  self   :					Optional[Any]					):


          """simple docstring"""



          return (
              F" Prev -> {self._prev is not None}, Next -> {self._next is not None}"
          )



  def __init__(  self   :					Any					):


        """simple docstring"""



        _lowerCAmelCase		   =   self._Node(__lowerCAmelCase					,					__lowerCAmelCase					,					__lowerCAmelCase					)
        _lowerCAmelCase		   =   self._Node(__lowerCAmelCase					,					__lowerCAmelCase					,					__lowerCAmelCase					)
        _lowerCAmelCase		   =   self._trailer
        _lowerCAmelCase		   =   self._header
        _lowerCAmelCase		   =   0



  def __len__(  self   :					Optional[Any]					):


        """simple docstring"""



        return self._size



  def   a   (  self   :					Optional[int]					):


        """simple docstring"""



        return self.__len__() == 0



  def   a   (  self   :					List[str]					,					__lowerCAmelCase   :					List[str]					,					__lowerCAmelCase   :					Optional[Any]					,					__lowerCAmelCase   :					Optional[Any]					):


        """simple docstring"""



        _lowerCAmelCase		   =   self._Node(__lowerCAmelCase					,					__lowerCAmelCase					,					__lowerCAmelCase					)
        _lowerCAmelCase		   =   new_node
        _lowerCAmelCase		   =   new_node
        self._size += 1
        return self



  def   a   (  self   :					Any					,					__lowerCAmelCase   :					Dict					):


        """simple docstring"""



        _lowerCAmelCase		   =   node._prev
        _lowerCAmelCase		   =   node._next

        _lowerCAmelCase		   =   successor
        _lowerCAmelCase		   =   predecessor
        self._size -= 1
        _lowerCAmelCase		   =   node._data
        _lowerCAmelCase		   =   _lowerCAmelCase		   =   _lowerCAmelCase		   =   None
        del node
        return temp





class        SCREAMING_SNAKE_CASE   (				_DoublyLinkedBase ):
  """simple docstring"""







  def   a   (  self   :					str					):


        """simple docstring"""



        if self.is_empty():
              raise Exception('List is empty'					)
        return self._header._next._data



  def   a   (  self   :					Tuple					):


        """simple docstring"""



        if self.is_empty():
              raise Exception('List is empty'					)
        return self._trailer._prev._data



  def   a   (  self   :					Dict					,					__lowerCAmelCase   :					Union[str, Any]					):


        """simple docstring"""



        return self._insert(self._header					,					__lowerCAmelCase					,					self._header._next					)



  def   a   (  self   :					List[Any]					,					__lowerCAmelCase   :					Dict					):


        """simple docstring"""



        return self._insert(self._trailer._prev					,					__lowerCAmelCase					,					self._trailer					)



  def   a   (  self   :					Union[str, Any]					):


        """simple docstring"""



        if self.is_empty():
              raise IndexError('remove_first from empty list'					)
        return self._delete(self._header._next					)



  def   a   (  self   :					Any					):


        """simple docstring"""



        if self.is_empty():
              raise IndexError('remove_first from empty list'					)
        return self._delete(self._trailer._prev					)






'''simple docstring'''




import itertools







def 			A_   ( _lowerCamelCase			:							Tuple    ):
      return (
          int(''.join(combination[0:2]    )    ) * int(''.join(combination[2:5]    )    )
          == int(''.join(combination[5:9]    )    )
      ) or (
          int(''.join(combination[0]    )    ) * int(''.join(combination[1:5]    )    )
          == int(''.join(combination[5:9]    )    )
      )







def 			A_   ( ):
      return sum(
          {
              int(''.join(pandigital[5:9]    )    )
              for pandigital in itertools.permutations('123456789'    )
              if is_combination_valid(_lowerCamelCase    )
          }    )


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





