
import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
					from PIL import Image


class 							lowercase   (						unittest.TestCase    ,  SCREAMING_SNAKE_CASE__  ):



		def __UpperCamelCase					(					self			)    ->   Optional[int]:
				"""simple docstring"""
				UpperCamelCase            =	load_tool('image-question-answering'			)
				self.tool.setup()
				UpperCamelCase            =	load_tool('image-question-answering'							, remote=lowerCAmelCase_			)



		def __UpperCamelCase					(					self			)    ->   Tuple:
				"""simple docstring"""
				UpperCamelCase            =	Image.open(Path(get_tests_dir('fixtures/tests_samples/COCO'			)			) / '000000039769.png'			)
				UpperCamelCase            =	self.tool(lowerCAmelCase_							, 'How many cats are sleeping on the couch?'			)
				self.assertEqual(lowerCAmelCase_							, '2'			)



		def __UpperCamelCase					(					self			)    ->   List[str]:
				"""simple docstring"""
				UpperCamelCase            =	Image.open(Path(get_tests_dir('fixtures/tests_samples/COCO'			)			) / '000000039769.png'			)
				UpperCamelCase            =	self.remote_tool(lowerCAmelCase_							, 'How many cats are sleeping on the couch?'			)
				self.assertEqual(lowerCAmelCase_							, '2'			)



		def __UpperCamelCase					(					self			)    ->   Any:
				"""simple docstring"""
				UpperCamelCase            =	Image.open(Path(get_tests_dir('fixtures/tests_samples/COCO'			)			) / '000000039769.png'			)
				UpperCamelCase            =	self.tool(image=lowerCAmelCase_							, question='How many cats are sleeping on the couch?'			)
				self.assertEqual(lowerCAmelCase_							, '2'			)



		def __UpperCamelCase					(					self			)    ->   int:
				"""simple docstring"""
				UpperCamelCase            =	Image.open(Path(get_tests_dir('fixtures/tests_samples/COCO'			)			) / '000000039769.png'			)
				UpperCamelCase            =	self.remote_tool(image=lowerCAmelCase_							, question='How many cats are sleeping on the couch?'			)
				self.assertEqual(lowerCAmelCase_							, '2'			)


from __future__ import annotations






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






def     lowerCamelCase__				(   a ) ->  List[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     lowerCamelCase__				(   ) ->  str:
   global graph, reversed_graph, scc, component, visit, stack
   for i in range(a ):
      dfs(a )
   _A:    Optional[Any]						     =			[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__						:	Any	     = 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__						:	str	     = 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())



