'''simple docstring'''




import os

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

_lowercase		:					Optional[Any]													=		{"UserAgent": UserAgent().random}
_lowercase		:					str													=		"https://www.mywaifulist.moe/random"




def 				lowerCamelCase      ( UpperCAmelCase__			:   str , UpperCAmelCase__			:   str					)     -> None:
							lowercase_   :     Optional[int]									=			requests.get(UpperCAmelCase__ , headers=UpperCAmelCase__					)
							with open(UpperCAmelCase__ , """wb"""					) as file:
														file.write(image.content					)




def 				lowerCamelCase      ( )     -> tuple[str, str, str]:
							lowercase_   :     int									=			BeautifulSoup(requests.get(UpperCAmelCase__ , headers=UpperCAmelCase__					).text , """html.parser"""					)
							lowercase_   :     Dict									=			soup.find("""meta""" , attrs={"""property""": """og:title"""}					).attrs["""content"""]
							lowercase_   :     Union[str, Any]									=			soup.find("""meta""" , attrs={"""property""": """og:image"""}					).attrs["""content"""]
							lowercase_   :     Optional[Any]									=			soup.find("""p""" , id="""description"""					).get_text()
							lowercase_		,		lowercase_   :     str									=			os.path.splitext(os.path.basename(UpperCAmelCase__					)					)
							lowercase_   :     str									=			title.strip().replace(""" """ , """_"""					)
							lowercase_   :     List[Any]									=			F'''{image_title}{image_extension}'''
							save_image(UpperCAmelCase__ , UpperCAmelCase__					)
							return (title, description, image_title)


if __name__ == "__main__":
						_lowercase							,			_lowercase							,			_lowercase		:					Union[str, Any]													=		random_anime_character()
						print(f"""{title}\n\n{desc}\n\nImage saved : {image_title}""")






'''simple docstring'''




from __future__ import annotations




def 				lowerCamelCase      ( UpperCAmelCase__			:   str					)     -> Any:
							global graph, reversed_graph, scc, component, visit, stack
							if visit[u]:
														return
							lowercase_   :     int									=			True
							for v in graph[u]:
														dfs(UpperCAmelCase__					)
							stack.append(UpperCAmelCase__					)




def 				lowerCamelCase      ( UpperCAmelCase__			:   int					)     -> str:
							global graph, reversed_graph, scc, component, visit, stack
							if visit[u]:
														return
							lowercase_   :     Tuple									=			True
							component.append(UpperCAmelCase__					)
							for v in reversed_graph[u]:
														dfsa(UpperCAmelCase__					)




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


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

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

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





