



"""simple docstring"""

from __future__ import annotations
def    __snake_case       (  __A			:	List[str]    )    ->					Tuple:






				'''simple docstring'''
				global graph, reversed_graph, scc, component, visit, stack
				if visit[u]:
								return
				SCREAMING_SNAKE_CASE	:       Dict 							=    True
				for v in graph[u]:
								dfs(__A    )
				stack.append(__A    )
def    __snake_case       (  __A			:	Dict    )    ->					str:






				'''simple docstring'''
				global graph, reversed_graph, scc, component, visit, stack
				if visit[u]:
								return
				SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    True
				component.append(__A    )
				for v in reversed_graph[u]:
								dfsa(__A    )
def    __snake_case       (  )    ->					List[str]:






				'''simple docstring'''
				global graph, reversed_graph, scc, component, visit, stack
				for i in range(__A    ):
								dfs(__A    )
				SCREAMING_SNAKE_CASE	:       Tuple 							=    [False] * n
				for i in stack[::-1]:
								if visit[i]:
												continue
								SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    []
								dfsa(__A    )
								scc.append(__A    )
				return scc


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

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

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






"""simple docstring"""

def    __snake_case       (  __A			:	int    )    ->					int:






				'''simple docstring'''
				if not isinstance(__A       ,		__A    ):
								raise ValueError('double_factorial() only accepts integral values'    )
				if num < 0:
								raise ValueError('double_factorial() not defined for negative values'    )
				SCREAMING_SNAKE_CASE	:       List[str] 							=    1
				for i in range(__A       ,		0       ,		-2    ):
								value *= i
				return value


if __name__ == "__main__":
							import doctest

							doctest.testmod()





