
'''simple docstring'''





import unittest

from cer import CER


a__						:				Any           =    CER()


class 	UpperCamelCase__					(      unittest.TestCase):






 def 		lowercase_  (     self					:int     )			->     Any:







       '''simple docstring'''



       __A    		=     ['White House']
       __A    		=     ['white house']
       # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.1_818_181_818     ) < 1E-6     )






 def 		lowercase_  (     self					:Tuple     )			->     str:







       '''simple docstring'''



       __A    		=     ['were wolf']
       __A    		=     ['werewolf']
       # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.1_111_111     ) < 1E-6     )

       __A    		=     ['werewolf']
       __A    		=     ['weae     wolf']
       # S = 1, D = 1, I = 0, N = 8, CER = 0.25
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.25     ) < 1E-6     )

       # consecutive whitespaces case 1
       __A    		=     ['were wolf']
       __A    		=     ['were               wolf']
       # S = 0, D = 0, I = 0, N = 9, CER = 0
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.0     ) < 1E-6     )

       # consecutive whitespaces case 2
       __A    		=     ['were   wolf']
       __A    		=     ['were               wolf']
       # S = 0, D = 0, I = 0, N = 9, CER = 0
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.0     ) < 1E-6     )






 def 		lowercase_  (     self					:str     )			->     List[Any]:







       '''simple docstring'''



       __A    		=     ['werewolf']
       __A    		=     ['weaewolf']
       # S = 1, D = 0, I = 0, N = 8, CER = 0.125
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.125     ) < 1E-6     )






 def 		lowercase_  (     self					:Optional[Any]     )			->     List[str]:







       '''simple docstring'''



       __A    		=     ['werewolf']
       __A    		=     ['wereawolf']
       # S = 0, D = 1, I = 0, N = 8, CER = 0.125
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.125     ) < 1E-6     )






 def 		lowercase_  (     self					:List[str]     )			->     Optional[int]:







       '''simple docstring'''



       __A    		=     ['werewolf']
       __A    		=     ['wereolf']
       # S = 0, D = 0, I = 1, N = 8, CER = 0.125
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.125     ) < 1E-6     )






 def 		lowercase_  (     self					:str     )			->     List[str]:







       '''simple docstring'''



       __A    		=     ['werewolf']
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertEqual(_A		,			0.0     )






 def 		lowercase_  (     self					:Optional[int]     )			->     Any:







       '''simple docstring'''



       __A    		=     ['werewolf', 'I am your father']
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertEqual(_A		,			0.0     )

       __A    		=     ['werewolf', 'I am your father', 'doge']
       __A    		=     ['werxwolf', 'I       am your father', 'doge']
       # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.03_571_428     ) < 1E-6     )






 def 		lowercase_  (     self					:List[str]     )			->     List[Any]:







       '''simple docstring'''



       __A    		=     ['My hovercraft', 'is full of eels']
       __A    		=     ['My hovercraft is full', ' of eels']
       # S = 0, D = 0, I = 2, N = 28, CER = 2 / 28
       # whitespace at the front of " of eels" will be strip during preporcessing
       # so need to insert 2 whitespaces
       __A    		=     cer.compute(predictions=_A		,			references=_A		,			concatenate_texts=_A     )
       self.assertTrue(abs(char_error_rate - 0.071_428     ) < 1E-6     )






 def 		lowercase_  (     self					:Any     )			->     str:







       '''simple docstring'''



       __A    		=     ['我能吞下玻璃而不伤身体']
       __A    		=     [' 能吞虾玻璃而 不霜身体啦']
       # S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.4_545_454_545     ) < 1E-6     )

       __A    		=     ['我能吞下玻璃', '而不伤身体']
       __A    		=     ['我    能 吞 下 玻 璃', '而不伤身体']
       # S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertTrue(abs(char_error_rate - 0.454_545_454_545     ) < 1E-6     )

       __A    		=     ['我能吞下玻璃而不伤身体']
       __A    		=     cer.compute(predictions=_A		,			references=_A     )
       self.assertFalse(_A		,			0.0     )






 def 		lowercase_  (     self					:List[Any]     )			->     Any:







       '''simple docstring'''



       __A    		=     ['']
       __A    		=     ['Hypothesis']
       with self.assertRaises(_A     ):
             cer.compute(predictions=_A		,			references=_A     )


if __name__ == "__main__":
 unittest.main()








'''simple docstring'''





from __future__ import annotations





def     snake_case							(						UpperCAmelCase		)->     List[Any]:







      """simple docstring"""
      global graph, reversed_graph, scc, component, visit, stack
      if visit[u]:
            return
      __A    		=     True
      for v in graph[u]:
            dfs(UpperCAmelCase		)
      stack.append(UpperCAmelCase		)





def     snake_case							(						UpperCAmelCase		)->     List[Any]:







      """simple docstring"""
      global graph, reversed_graph, scc, component, visit, stack
      if visit[u]:
            return
      __A    		=     True
      component.append(UpperCAmelCase		)
      for v in reversed_graph[u]:
            dfsa(UpperCAmelCase		)





def     snake_case							(						)->     Any:







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


if __name__ == "__main__":
 # n - no of nodes, m - no of edges
 a__    ,						a__						:				Tuple           =    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__    ,						a__						:				Tuple           =    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())






