




'''simple docstring'''




from abc import ABC, abstractmethod
from typing import List, Optional






class   _SCREAMING_SNAKE_CASE   (   _lowerCamelCase     ):



 def __init__(   self		:   Dict      ):
      # test for the above condition
      self.test()



 def 			snake_case__  (   self		:   int      ):
      __magic_name__						       =    0
      __magic_name__						       =    False
      while not completed:
           if counter == 1:
                self.reset()
           __magic_name__						       =    self.advance()
           if not self.does_advance(lowercase_      ):
                raise Exception(
                    '''Custom Constraint is not defined correctly. self.does_advance(self.advance()) must be true.'''      )

           __magic_name__       ,  __magic_name__       ,  __magic_name__						       =    self.update(lowercase_      )
           counter += 1

           if counter > 1_0000:
                raise Exception('''update() does not fulfill the constraint.'''      )

      if self.remaining() != 0:
           raise Exception('''Custom Constraint is not defined correctly.'''      )



 @abstractmethod
 def 			snake_case__  (   self		:   Optional[Any]      ):
      raise NotImplementedError(
          F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''      )



 @abstractmethod
 def 			snake_case__  (   self		:   Tuple			,				a__		:   int      ):
      raise NotImplementedError(
          F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''      )



 @abstractmethod
 def 			snake_case__  (   self		:   str			,				a__		:   int      ):
      raise NotImplementedError(
          F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''      )



 @abstractmethod
 def 			snake_case__  (   self		:   Any      ):
      raise NotImplementedError(
          F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''      )



 @abstractmethod
 def 			snake_case__  (   self		:   Tuple      ):
      raise NotImplementedError(
          F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''      )



 @abstractmethod
 def 			snake_case__  (   self		:   Tuple			,				a__		:   int=False      ):
      raise NotImplementedError(
          F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''      )






class   _SCREAMING_SNAKE_CASE   (   _lowerCamelCase     ):



 def __init__(   self		:   Optional[int]			,				a__		:   List[int]      ):
      super(lowercase_			,				self      ).__init__()

      if not isinstance(lowercase_			,				lowercase_      ) or len(lowercase_      ) == 0:
           raise ValueError(F'''`token_ids` has to be a non-empty list, but is {token_ids}.'''      )
      if any((not isinstance(lowercase_			,				lowercase_      ) or token_id < 0) for token_id in token_ids      ):
           raise ValueError(F'''Each list in `token_ids` has to be a list of positive integers, but is {token_ids}.'''      )

      __magic_name__						       =    token_ids

      __magic_name__						       =    len(self.token_ids      )
      __magic_name__						       =    -1  # the index of the currently fulfilled step
      __magic_name__						       =    False



 def 			snake_case__  (   self		:   Optional[int]      ):
      if self.completed:
           return None
      return self.token_ids[self.fulfilled_idx + 1]



 def 			snake_case__  (   self		:   Optional[int]			,				a__		:   int      ):
      if not isinstance(lowercase_			,				lowercase_      ):
           raise ValueError(F'''`token_id` has to be an `int`, but is {token_id} of type {type(lowercase_      )}'''      )

      if self.completed:
           return False

      return token_id == self.token_ids[self.fulfilled_idx + 1]



 def 			snake_case__  (   self		:   List[str]			,				a__		:   int      ):
      if not isinstance(lowercase_			,				lowercase_      ):
           raise ValueError(F'''`token_id` has to be an `int`, but is {token_id} of type {type(lowercase_      )}'''      )

      __magic_name__						       =    False
      __magic_name__						       =    False
      __magic_name__						       =    False

      if self.does_advance(lowercase_      ):
           self.fulfilled_idx += 1
           __magic_name__						       =    True
           if self.fulfilled_idx == (self.seqlen - 1):
                __magic_name__						       =    True
           __magic_name__						       =    completed
      else:
           # failed to make progress.
           __magic_name__						       =    True
           self.reset()
      return stepped, completed, reset



 def 			snake_case__  (   self		:   Optional[Any]      ):
      __magic_name__						       =    False
      __magic_name__						       =    0



 def 			snake_case__  (   self		:   List[str]      ):
      return self.seqlen - (self.fulfilled_idx + 1)



 def 			snake_case__  (   self		:   int			,				a__		:   str=False      ):
      __magic_name__						       =    PhrasalConstraint(self.token_ids      )

      if stateful:
           __magic_name__						       =    self.seqlen
           __magic_name__						       =    self.fulfilled_idx
           __magic_name__						       =    self.completed

      return new_constraint






class   _SCREAMING_SNAKE_CASE   :



 def __init__(   self		:   Tuple			,				a__		:   List[List[int]]			,				a__		:   str=True      ):
      __magic_name__						       =    max([len(lowercase_      ) for one in nested_token_ids]      )

      __magic_name__						       =    {}
      for token_ids in nested_token_ids:
           __magic_name__						       =    root
           for tidx, token_id in enumerate(lowercase_      ):
                if token_id not in level:
                     __magic_name__						       =    {}

                __magic_name__						       =    level[token_id]

      if no_subsets and self.has_subsets(lowercase_			,				lowercase_      ):
           raise ValueError(
               '''Each list in `nested_token_ids` can\'t be a complete subset of another list, but is'''
               F''' {nested_token_ids}.'''      )

      __magic_name__						       =    root



 def 			snake_case__  (   self		:   Optional[int]			,				a__		:   List[Any]      ):
      __magic_name__						       =    self.trie

      for current_token in current_seq:
           __magic_name__						       =    start[current_token]

      __magic_name__						       =    list(start.keys()      )

      return next_tokens



 def 			snake_case__  (   self		:   Optional[Any]			,				a__		:   Tuple      ):
      __magic_name__						       =    self.next_tokens(lowercase_      )

      return len(lowercase_      ) == 0



 def 			snake_case__  (   self		:   str			,				a__		:   List[str]      ):
      __magic_name__						       =    list(root.values()      )
      if len(lowercase_      ) == 0:
           return 1
      else:
           return sum([self.count_leaves(lowercase_      ) for nn in next_nodes]      )



 def 			snake_case__  (   self		:   Dict			,				a__		:   Optional[int]			,				a__		:   List[str]      ):
      __magic_name__						       =    self.count_leaves(lowercase_      )
      return len(lowercase_      ) != leaf_count






class   _SCREAMING_SNAKE_CASE   (   _lowerCamelCase     ):



 def __init__(   self		:   Tuple			,				a__		:   List[List[int]]      ):
      super(lowercase_			,				self      ).__init__()

      if not isinstance(lowercase_			,				lowercase_      ) or len(lowercase_      ) == 0:
           raise ValueError(F'''`nested_token_ids` has to be a non-empty list, but is {nested_token_ids}.'''      )
      if any(not isinstance(lowercase_			,				lowercase_      ) for token_ids in nested_token_ids      ):
           raise ValueError(F'''`nested_token_ids` has to be a list of lists, but is {nested_token_ids}.'''      )
      if any(
          any((not isinstance(lowercase_			,				lowercase_      ) or token_id < 0) for token_id in token_ids      )
          for token_ids in nested_token_ids      ):
           raise ValueError(
               F'''Each list in `nested_token_ids` has to be a list of positive integers, but is {nested_token_ids}.'''      )

      __magic_name__						       =    DisjunctiveTrie(lowercase_      )
      __magic_name__						       =    nested_token_ids

      __magic_name__						       =    self.trie.max_height
      __magic_name__						       =    []
      __magic_name__						       =    False



 def 			snake_case__  (   self		:   str      ):
      __magic_name__						       =    self.trie.next_tokens(self.current_seq      )

      if len(lowercase_      ) == 0:
           return None
      else:
           return token_list



 def 			snake_case__  (   self		:   str			,				a__		:   int      ):
      if not isinstance(lowercase_			,				lowercase_      ):
           raise ValueError(F'''`token_id` is supposed to be type `int`, but is {token_id} of type {type(lowercase_      )}'''      )

      __magic_name__						       =    self.trie.next_tokens(self.current_seq      )

      return token_id in next_tokens



 def 			snake_case__  (   self		:   List[Any]			,				a__		:   int      ):
      if not isinstance(lowercase_			,				lowercase_      ):
           raise ValueError(F'''`token_id` is supposed to be type `int`, but is {token_id} of type {type(lowercase_      )}'''      )

      __magic_name__						       =    False
      __magic_name__						       =    False
      __magic_name__						       =    False

      if self.does_advance(lowercase_      ):
           self.current_seq.append(lowercase_      )
           __magic_name__						       =    True
      else:
           __magic_name__						       =    True
           self.reset()

      __magic_name__						       =    self.trie.reached_leaf(self.current_seq      )
      __magic_name__						       =    completed

      return stepped, completed, reset



 def 			snake_case__  (   self		:   Optional[Any]      ):
      __magic_name__						       =    False
      __magic_name__						       =    []



 def 			snake_case__  (   self		:   str      ):
      if self.completed:
           # since this can be completed without reaching max height
           return 0
      else:
           return self.seqlen - len(self.current_seq      )



 def 			snake_case__  (   self		:   Optional[Any]			,				a__		:   Tuple=False      ):
      __magic_name__						       =    DisjunctiveConstraint(self.token_ids      )

      if stateful:
           __magic_name__						       =    self.seqlen
           __magic_name__						       =    self.current_seq
           __magic_name__						       =    self.completed

      return new_constraint






class   _SCREAMING_SNAKE_CASE   :



 def __init__(   self		:   List[Any]			,				a__		:   List[Constraint]      ):
      __magic_name__						       =    constraints

      # max # of steps required to fulfill a given constraint
      __magic_name__						       =    max([c.seqlen for c in constraints]      )
      __magic_name__						       =    len(lowercase_      )
      __magic_name__						       =    False

      self.init_state()



 def 			snake_case__  (   self		:   Optional[int]      ):
      __magic_name__						       =    []
      __magic_name__						       =    None
      __magic_name__						       =    [constraint.copy(stateful=lowercase_      ) for constraint in self.constraints]



 def 			snake_case__  (   self		:   Optional[Any]      ):
      __magic_name__						       =    0
      if self.inprogress_constraint:
           # extra points for having a constraint mid-fulfilled
           add += self.max_seqlen - self.inprogress_constraint.remaining()

      return (len(self.complete_constraints      ) * self.max_seqlen) + add



 def 			snake_case__  (   self		:   Any      ):
      __magic_name__						       =    []
      if self.inprogress_constraint is None:
           for constraint in self.pending_constraints:  # "pending" == "unfulfilled yet"
                __magic_name__						       =    constraint.advance()
                if isinstance(lowercase_			,				lowercase_      ):
                     token_list.append(lowercase_      )
                elif isinstance(lowercase_			,				lowercase_      ):
                     token_list.extend(lowercase_      )
      else:
           __magic_name__						       =    self.inprogress_constraint.advance()
           if isinstance(lowercase_			,				lowercase_      ):
                token_list.append(lowercase_      )
           elif isinstance(lowercase_			,				lowercase_      ):
                token_list.extend(lowercase_      )

      if len(lowercase_      ) == 0:
           return None
      else:
           return token_list



 def 			snake_case__  (   self		:   int			,				a__		:   Optional[List[int]]      ):
      self.init_state()

      if token_ids is not None:
           for token in token_ids:
                # completes or steps **one** constraint
                __magic_name__       ,  __magic_name__						       =    self.add(lowercase_      )

                # the entire list of constraints are fulfilled
                if self.completed:
                     break



 def 			snake_case__  (   self		:   Dict			,				a__		:   int      ):
      if not isinstance(lowercase_			,				lowercase_      ):
           raise ValueError(F'''`token_id` should be an `int`, but is `{token_id}`.'''      )

      __magic_name__       ,  __magic_name__						       =    False, False

      if self.completed:
           __magic_name__						       =    True
           __magic_name__						       =    False
           return complete, stepped

      if self.inprogress_constraint is not None:
           # In the middle of fulfilling a constraint. If the `token_id` *does* makes an incremental progress to current
           # job, simply update the state

           __magic_name__       ,  __magic_name__       ,  __magic_name__						       =    self.inprogress_constraint.update(lowercase_      )
           if reset:
                # 1. If the next token breaks the progress, then we must restart.
                #     e.g. constraint = "I love pies" and sequence so far is "I love" but `token_id` == "books".

                #     But that doesn't mean we self.init_state(), since we only reset the state for this particular
                #     constraint, not the full list of constraints.

                self.pending_constraints.append(self.inprogress_constraint.copy(stateful=lowercase_      )      )
                __magic_name__						       =    None

           if complete:
                # 2. If the next token completes the constraint, move it to completed list, set
                #     inprogress to None. If there are no pending constraints either, then this full list of constraints
                #     is complete.

                self.complete_constraints.append(self.inprogress_constraint      )
                __magic_name__						       =    None

                if len(self.pending_constraints      ) == 0:
                     # we're done!
                     __magic_name__						       =    True

      else:
           # Not in the middle of fulfilling a constraint. So does this `token_id` helps us step towards any of our list
           # of constraints?

           for cidx, pending_constraint in enumerate(self.pending_constraints      ):
                if pending_constraint.does_advance(lowercase_      ):
                     __magic_name__       ,  __magic_name__       ,  __magic_name__						       =    pending_constraint.update(lowercase_      )

                     if not stepped:
                          raise Exception(
                              '''`constraint.update(token_id)` is not yielding incremental progress, '''
                              '''even though `constraint.does_advance(token_id)` is true.'''      )

                     if complete:
                          self.complete_constraints.append(lowercase_      )
                          __magic_name__						       =    None

                     if not complete and stepped:
                          __magic_name__						       =    pending_constraint

                     if complete or stepped:
                          # If we made any progress at all, then it's at least not a "pending constraint".

                          __magic_name__						       =    (
                              self.pending_constraints[:cidx] + self.pending_constraints[cidx + 1 :]
                          )

                          if len(self.pending_constraints      ) == 0 and self.inprogress_constraint is None:
                               # If there's no longer any pending after this and no inprogress either, then we must be
                               # complete.

                               __magic_name__						       =    True

                          break  # prevent accidentally stepping through multiple constraints with just one token.

      return complete, stepped



 def 			snake_case__  (   self		:   Union[str, Any]			,				a__		:   str=True      ):
      __magic_name__						       =    ConstraintListState(self.constraints      )  # we actually never though self.constraints objects
      # throughout this process. So it's at initialization state.

      if stateful:
           __magic_name__						       =    [
               constraint.copy(stateful=lowercase_      ) for constraint in self.complete_constraints
           ]
           if self.inprogress_constraint is not None:
                __magic_name__						       =    self.inprogress_constraint.copy(stateful=lowercase_      )
           __magic_name__						       =    [constraint.copy() for constraint in self.pending_constraints]

      return new_state









'''simple docstring'''




from __future__ import annotations

from fractions import Fraction




def 						UpperCamelCase	(			a		,						a			)				->     bool:






     '''simple docstring'''
     return (
         num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den
     )




def 						UpperCamelCase	(			a			)				->     list[str]:






     '''simple docstring'''
     __magic_name__						       =    []
     __magic_name__						       =    11
     __magic_name__						       =    int('''1''' + '''0''' * digit_len			)
     for num in range(a		,						a			):
          while den <= 99:
               if (num != den) and (num % 10 == den // 10) and (den % 10 != 0):
                    if is_digit_cancelling(a		,						a			):
                         solutions.append(F'''{num}/{den}'''			)
               den += 1
          num += 1
          __magic_name__						       =    10
     return solutions




def 						UpperCamelCase	(			a = 2			)				->     int:






     '''simple docstring'''
     __magic_name__						       =    1.0
     for fraction in fraction_list(a			):
          __magic_name__						       =    Fraction(a			)
          result *= frac.denominator / frac.numerator
     return int(a			)


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






