





from typing import Any

import numpy as np







def 			_SCREAMING_SNAKE_CASE    (       a  )				->				bool:
					assert np.shape(a  )[0] == np.shape(a  )[1]

					# If matrix not symmetric, exit right away.
					if np.allclose(a ,						matrix.T  ) is False:
										return False

					# Get eigenvalues and eignevectors for a symmetric matrix.
					__A   ,    __A     :						int          =    np.linalg.eigh(a  )

					# Check sign of all eigenvalues.
					# np.all returns a value of type np.bool_
					return bool(np.all(eigen_values > 0  )  )







def 			_SCREAMING_SNAKE_CASE    (       a  )				->				Any:
					__A     :						Union[str, Any]          =    np.random.randn(a ,						a  )
					__A     :						List[str]          =    np.dot(a ,						random_matrix.T  )
					assert _is_matrix_spd(a  )
					return spd_matrix







def 			_SCREAMING_SNAKE_CASE    (       a ,						a ,						a = 10_00 ,						a = 1e-8 ,						)				->				Any:
					assert np.shape(a  )[0] == np.shape(a  )[1]
					assert np.shape(a  )[0] == np.shape(a  )[0]
					assert _is_matrix_spd(a  )

					# Initialize solution guess, residual, search direction.
					__A     :						int          =    np.zeros((np.shape(a  )[0], 1)  )
					__A     :						Optional[Any]          =    np.copy(a  )
					__A     :						Optional[Any]          =    np.copy(a  )

					# Set initial errors in solution guess and residual.
					__A     :						Dict          =    1e9
					__A     :						List[Any]          =    1e9
					__A     :						int          =    1e9

					# Set iteration counter to threshold number of iterations.
					__A     :						Tuple          =    0

					while error > tol:
										# Save this value so we only calculate the matrix-vector product once.
										__A     :						Optional[Any]          =    np.dot(a ,						a  )

										# The main algorithm.

										# Update search direction magnitude.
										__A     :						Dict          =    np.dot(ra.T ,						a  ) / np.dot(pa.T ,						a  )
										# Update solution guess.
										__A     :						Optional[Any]          =    xa + alpha * pa
										# Calculate new residual.
										__A     :						List[str]          =    ra - alpha * w
										# Calculate new Krylov subspace scale.
										__A     :						Optional[Any]          =    np.dot(r.T ,						a  ) / np.dot(ra.T ,						a  )
										# Calculate new A conjuage search direction.
										__A     :						int          =    r + beta * pa

										# Calculate errors.
										__A     :						List[str]          =    np.linalg.norm(r - ra  )
										__A     :						Union[str, Any]          =    np.linalg.norm(x - xa  )
										__A     :						Optional[int]          =    np.maximum(a ,						a  )

										# Update variables.
										__A     :						str          =    np.copy(a  )
										__A     :						Union[str, Any]          =    np.copy(a  )
										__A     :						Tuple          =    np.copy(a  )

										# Update number of iterations.
										iterations += 1
										if iterations > max_iterations:
															break

					return x







def 			_SCREAMING_SNAKE_CASE    (       )				->				None:
					__A     :						int          =    3
					__A     :						Dict          =    _create_spd_matrix(a  )
					__A     :						str          =    np.random.randn(a ,						1  )
					__A     :						Optional[Any]          =    np.dot(a ,						a  )

					# Numpy solution.
					__A     :						Tuple          =    np.linalg.solve(a ,						a  )

					# Our implementation.
					__A     :						Optional[Any]          =    conjugate_gradient(a ,						a  )

					# Ensure both solutions are close to x_true (and therefore one another).
					assert np.linalg.norm(x_numpy - x_true  ) <= 1e-6
					assert np.linalg.norm(x_conjugate_gradient - x_true  ) <= 1e-6


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				test_conjugate_gradient()











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())




