





from collections import deque



def        __lowercase       (				_SCREAMING_SNAKE_CASE     )			->       Tuple:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						len(_UpperCAmelCase     )
      SCREAMING_SNAKE_CASE		=						deque()
      SCREAMING_SNAKE_CASE		=						[False for _ in range(_UpperCAmelCase     )]
      SCREAMING_SNAKE_CASE		=						[-1 for _ in range(_UpperCAmelCase     )]
      SCREAMING_SNAKE_CASE		=						index_of[:]

      def strong_connect(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE     ):
            SCREAMING_SNAKE_CASE		=						index  # the number when this node is seen
            SCREAMING_SNAKE_CASE		=						index  # lowest rank node reachable from here
            index += 1
            stack.append(_UpperCAmelCase     )
            SCREAMING_SNAKE_CASE		=						True

            for w in g[v]:
                  if index_of[w] == -1:
                        SCREAMING_SNAKE_CASE		=						strong_connect(_UpperCAmelCase			,						_UpperCAmelCase			,						_UpperCAmelCase     )
                        SCREAMING_SNAKE_CASE		=						(
                            lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
                        )
                  elif on_stack[w]:
                        SCREAMING_SNAKE_CASE		=						(
                            lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
                        )

            if lowlink_of[v] == index_of[v]:
                  SCREAMING_SNAKE_CASE		=						[]
                  SCREAMING_SNAKE_CASE		=						stack.pop()
                  SCREAMING_SNAKE_CASE		=						False
                  component.append(_UpperCAmelCase     )
                  while w != v:
                        SCREAMING_SNAKE_CASE		=						stack.pop()
                        SCREAMING_SNAKE_CASE		=						False
                        component.append(_UpperCAmelCase     )
                  components.append(_UpperCAmelCase     )
            return index

      SCREAMING_SNAKE_CASE		=						[]
      for v in range(_UpperCAmelCase     ):
            if index_of[v] == -1:
                  strong_connect(_UpperCAmelCase			,						0			,						_UpperCAmelCase     )

      return components



def        __lowercase       (				_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE     )			->       Optional[Any]:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						[[] for _ in range(_UpperCAmelCase     )]
      for u, v in edges:
            g[u].append(_UpperCAmelCase     )
      return g


if __name__ == "__main__":
      # Test
      SCREAMING_SNAKE_CASE_						       =   7
      SCREAMING_SNAKE_CASE_						       =   [0, 0, 1, 2, 3, 3, 4, 4, 6]
      SCREAMING_SNAKE_CASE_						       =   [1, 3, 2, 0, 1, 4, 5, 6, 5]
      SCREAMING_SNAKE_CASE_						       =   [(u, v) for u, v in zip(source, target)]
      SCREAMING_SNAKE_CASE_						       =   create_graph(n_vertices, edges)

      assert [[5], [6], [4], [3, 2, 1, 0]] == tarjan(g)









from itertools import permutations



def        __lowercase       (				_SCREAMING_SNAKE_CASE     )			->       bool:


      '''simple docstring'''


      if num[3] % 2 != 0:
            return False

      if (num[2] + num[3] + num[4]) % 3 != 0:
            return False

      if num[5] % 5 != 0:
            return False

      SCREAMING_SNAKE_CASE		=						[7, 11, 13, 17]
      for i, test in enumerate(_SCREAMING_SNAKE_CASE     ):
            if (num[i + 4] * 1_00 + num[i + 5] * 10 + num[i + 6]) % test != 0:
                  return False
      return True



def        __lowercase       (				_SCREAMING_SNAKE_CASE = 10     )			->       int:


      '''simple docstring'''


      return sum(
          int("""""".join(map(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE     )     )     )
          for num in permutations(range(_SCREAMING_SNAKE_CASE     )     )
          if is_substring_divisible(_SCREAMING_SNAKE_CASE     )     )


if __name__ == "__main__":
      print(F'''{solution() = }''')


