





from .balanced_parentheses import balanced_parentheses
from .stack import Stack







def 			_SCREAMING_SNAKE_CASE    (       a  )				->				int:
					return {"+": 1, "-": 1, "*": 2, "/": 2, "^": 3}.get(SCREAMING_SNAKE_CASE_ ,						-1  )







def 			_SCREAMING_SNAKE_CASE    (       a  )				->				str:





					if not balanced_parentheses(SCREAMING_SNAKE_CASE_  ):
										raise ValueError('Mismatched parentheses'  )
					__A     :						str          =    Stack()
					__A     :						Tuple          =    []
					for char in expression_str:
										if char.isalpha() or char.isdigit():
															postfix.append(SCREAMING_SNAKE_CASE_  )
										elif char == "(":
															stack.push(SCREAMING_SNAKE_CASE_  )
										elif char == ")":
															while not stack.is_empty() and stack.peek() != "(":
																				postfix.append(stack.pop()  )
															stack.pop()
										else:
															while not stack.is_empty() and precedence(SCREAMING_SNAKE_CASE_  ) <= precedence(stack.peek()  ):
																				postfix.append(stack.pop()  )
															stack.push(SCREAMING_SNAKE_CASE_  )
					while not stack.is_empty():
										postfix.append(stack.pop()  )
					return " ".join(SCREAMING_SNAKE_CASE_  )


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

				testmod()
				UpperCAmelCase						:       Any        =					'''a+b*(c^d-e)^(f+g*h)-i'''

				print('''Infix to Postfix Notation demonstration:\n''')
				print('''Infix notation: ''' + expression)
				print('''Postfix notation: ''' + infix_to_postfix(expression))











from __future__ import annotations







def 			_SCREAMING_SNAKE_CASE    (       a  )				->				List[str]:
					global graph, reversed_graph, scc, component, visit, stack
					if visit[u]:
										return
					__A     :						List[Any]          =    True
					for v in graph[u]:
										dfs(a  )
					stack.append(a  )







def 			_SCREAMING_SNAKE_CASE    (       a  )				->				Optional[Any]:
					global graph, reversed_graph, scc, component, visit, stack
					if visit[u]:
										return
					__A     :						str          =    True
					component.append(a  )
					for v in reversed_graph[u]:
										dfsa(a  )







def 			_SCREAMING_SNAKE_CASE    (       )				->				Optional[int]:
					global graph, reversed_graph, scc, component, visit, stack
					for i in range(a  ):
										dfs(a  )
					__A     :						str          =    [False] * n
					for i in stack[::-1]:
										if visit[i]:
															continue
										__A     :						Optional[Any]          =    []
										dfsa(a  )
										scc.append(a  )
					return scc


if __name__ == "__main__":
				# n - no of nodes, m - no of edges
				UpperCAmelCase  ,			UpperCAmelCase						:       List[str]        =					list(map(int, input().strip().split()))

				UpperCAmelCase						:       list[list[int]]        =					[[] for _ in range(n)]  # graph
				UpperCAmelCase						:       list[list[int]]        =					[[] for i in range(n)]  # reversed graph
				# input graph data (edges)
				for _ in range(m):
								UpperCAmelCase  ,			UpperCAmelCase						:       int        =					list(map(int, input().strip().split()))
								graph[u].append(v)
								reversed_graph[v].append(u)

				UpperCAmelCase						:       list[int]        =					[]
				UpperCAmelCase						:       list[bool]        =					[False] * n
				UpperCAmelCase						:       list[int]        =					[]
				UpperCAmelCase						:       list[int]        =					[]
				print(kosaraju())




