




from __future__ import annotations



def      UpperCAmelCase_   (     __UpperCamelCase     ):
    global graph, reversed_graph, scc, component, visit, stack
    if visit[u]:
        return
    SCREAMING_SNAKE_CASE__       =True
    for v in graph[u]:
        dfs(__UpperCamelCase     )
    stack.append(__UpperCamelCase     )



def      UpperCAmelCase_   (     __UpperCamelCase     ):
    global graph, reversed_graph, scc, component, visit, stack
    if visit[u]:
        return
    SCREAMING_SNAKE_CASE__       =True
    component.append(__UpperCamelCase     )
    for v in reversed_graph[u]:
        dfsa(__UpperCamelCase     )



def      UpperCAmelCase_   (     ):
    global graph, reversed_graph, scc, component, visit, stack
    for i in range(__UpperCamelCase     ):
        dfs(__UpperCamelCase     )
    SCREAMING_SNAKE_CASE__       =[False] * n
    for i in stack[::-1]:
        if visit[i]:
            continue
        SCREAMING_SNAKE_CASE__       =[]
        dfsa(__UpperCamelCase     )
        scc.append(__UpperCamelCase     )
    return scc


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

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

    lowerCamelCase_  						=       []
    lowerCamelCase_  						=       [False] * n
    lowerCamelCase_  						=       []
    lowerCamelCase_  						=       []
    print(kosaraju())












from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCamelCase_  						=       {
    "configuration_marian": ["MARIAN_PRETRAINED_CONFIG_ARCHIVE_MAP", "MarianConfig", "MarianOnnxConfig"],
}

try:
    if not is_sentencepiece_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCamelCase_  						=       ["MarianTokenizer"]

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCamelCase_  						=       [
        "MARIAN_PRETRAINED_MODEL_ARCHIVE_LIST",
        "MarianForCausalLM",
        "MarianModel",
        "MarianMTModel",
        "MarianPreTrainedModel",
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCamelCase_  						=       ["TFMarianModel", "TFMarianMTModel", "TFMarianPreTrainedModel"]

try:
    if not is_flax_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowerCamelCase_  						=       ["FlaxMarianModel", "FlaxMarianMTModel", "FlaxMarianPreTrainedModel"]

if TYPE_CHECKING:
    from .configuration_marian import MARIAN_PRETRAINED_CONFIG_ARCHIVE_MAP, MarianConfig, MarianOnnxConfig

    try:
        if not is_sentencepiece_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_marian import MarianTokenizer

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_marian import (
            MARIAN_PRETRAINED_MODEL_ARCHIVE_LIST,
            MarianForCausalLM,
            MarianModel,
            MarianMTModel,
            MarianPreTrainedModel,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_marian import TFMarianModel, TFMarianMTModel, TFMarianPreTrainedModel

    try:
        if not is_flax_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_flax_marian import FlaxMarianModel, FlaxMarianMTModel, FlaxMarianPreTrainedModel

else:
    import sys

    lowerCamelCase_  						=       _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)






