




from collections import deque




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						Optional[Any]      )  ->							Union[str, Any]:
    return input(__UpperCamelCase      ).strip().split(''' '''      )




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						int       ,     __UpperCamelCase			:						int      )  ->							dict[int, list[int]]:
    UpperCAmelCase_							 =     {}
    for i in range(__UpperCamelCase      ):
        UpperCAmelCase_							 =     []

    for e in range(__UpperCamelCase      ):
        UpperCAmelCase_ ,							UpperCAmelCase_							 =     (int(__UpperCamelCase      ) for i in _input(f'Edge {e + 1}: <node1> <node2> '      ))
        graph[x].append(__UpperCamelCase      )
    return graph




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						int       ,     __UpperCamelCase			:						int      )  ->							dict[int, list[int]]:
    UpperCAmelCase_							 =     {}
    for i in range(__UpperCamelCase      ):
        UpperCAmelCase_							 =     []

    for e in range(__UpperCamelCase      ):
        UpperCAmelCase_ ,							UpperCAmelCase_							 =     (int(__UpperCamelCase      ) for i in _input(f'Edge {e + 1}: <node1> <node2> '      ))
        graph[x].append(__UpperCamelCase      )
        graph[y].append(__UpperCamelCase      )
    return graph




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						int       ,     __UpperCamelCase			:						int      )  ->							dict[int, list[tuple[int, int]]]:
    UpperCAmelCase_							 =     {}
    for i in range(__UpperCamelCase      ):
        UpperCAmelCase_							 =     []

    for e in range(__UpperCamelCase      ):
        UpperCAmelCase_ ,							UpperCAmelCase_ ,							UpperCAmelCase_							 =     (int(__UpperCamelCase      ) for i in _input(f'Edge {e + 1}: <node1> <node2> <weight> '      ))
        graph[x].append((y, w)      )
        graph[y].append((x, w)      )
    return graph


if __name__ == "__main__":
 _lowerCamelCase ,     _lowerCamelCase			 =						(int(i) for i in _input('Number of nodes and edges: '))

 _lowerCamelCase			 =						int(
     _input(
         'Press 1 or 2 or 3 \n'
         '1. Unweighted directed \n'
         '2. Unweighted undirected \n'
         '3. Weighted undirected \n'
     )[0]
 )

 _lowerCamelCase			 =						{
     1: initialize_unweighted_directed_graph,
     2: initialize_unweighted_undirected_graph,
     3: initialize_weighted_undirected_graph,
 }[graph_choice](n, m)




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						Tuple       ,     __UpperCamelCase			:						Optional[int]      )  ->							Tuple:
    UpperCAmelCase_ ,							UpperCAmelCase_							 =     {s}, [s]
    print(__UpperCamelCase      )
    while _s:
        UpperCAmelCase_							 =     0
        for i in g[_s[-1]]:
            if i not in vis:
                _s.append(__UpperCamelCase      )
                vis.add(__UpperCamelCase      )
                UpperCAmelCase_							 =     1
                print(__UpperCamelCase      )
                break
        if not flag:
            _s.pop()




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						str       ,     __UpperCamelCase			:						List[str]      )  ->							Dict:
    UpperCAmelCase_ ,							UpperCAmelCase_							 =     {s}, deque([s]      )
    print(__UpperCamelCase      )
    while q:
        UpperCAmelCase_							 =     q.popleft()
        for v in g[u]:
            if v not in vis:
                vis.add(__UpperCamelCase      )
                q.append(__UpperCamelCase      )
                print(__UpperCamelCase      )




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						Union[str, Any]       ,     __UpperCamelCase			:						List[str]      )  ->							List[str]:
    UpperCAmelCase_ ,							UpperCAmelCase_ ,							UpperCAmelCase_							 =     {s: 0}, set(), {s: 0}
    while True:
        if len(__UpperCamelCase      ) == len(__UpperCamelCase      ) - 1:
            break
        UpperCAmelCase_							 =     10_0000
        for i in dist:
            if i not in known and dist[i] < mini:
                UpperCAmelCase_							 =     dist[i]
                UpperCAmelCase_							 =     i
        known.add(__UpperCamelCase      )
        for v in g[u]:
            if v[0] not in known and dist[u] + v[1] < dist.get(v[0]       ,     10_0000      ):
                UpperCAmelCase_							 =     dist[u] + v[1]
                UpperCAmelCase_							 =     u
    for i in dist:
        if i != s:
            print(dist[i]      )




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						Union[str, Any]       ,     __UpperCamelCase			:						Dict=None       ,     __UpperCamelCase			:						Dict=None      )  ->							List[str]:
    if q is None:
        UpperCAmelCase_							 =     [1]
    if ind is None:
        UpperCAmelCase_							 =     [0] * (len(__UpperCamelCase      ) + 1)  # SInce oth Index is ignored
        for u in g:
            for v in g[u]:
                ind[v] += 1
        UpperCAmelCase_							 =     deque()
        for i in g:
            if ind[i] == 0:
                q.append(__UpperCamelCase      )
    if len(__UpperCamelCase      ) == 0:
        return
    UpperCAmelCase_							 =     q.popleft()
    print(__UpperCamelCase      )
    for w in g[v]:
        ind[w] -= 1
        if ind[w] == 0:
            q.append(__UpperCamelCase      )
    topo(__UpperCamelCase       ,     __UpperCamelCase       ,     __UpperCamelCase      )




def 					SCREAMING_SNAKE_CASE	(       )  ->							str:
    UpperCAmelCase_							 =     input().strip()
    UpperCAmelCase_							 =     []
    for _ in range(__UpperCamelCase      ):
        a.append(map(__UpperCamelCase       ,     input().strip().split()      )      )
    return a, n




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						Optional[Any]      )  ->							Optional[Any]:
    ((UpperCAmelCase_) ,							(UpperCAmelCase_))							 =     a_and_n
    UpperCAmelCase_							 =     list(__UpperCamelCase      )
    UpperCAmelCase_							 =     [[0] * n for i in range(__UpperCamelCase      )]
    for k in range(__UpperCamelCase      ):
        for i in range(__UpperCamelCase      ):
            for j in range(__UpperCamelCase      ):
                if dist[i][j] > dist[i][k] + dist[k][j]:
                    UpperCAmelCase_							 =     dist[i][k] + dist[k][j]
                    UpperCAmelCase_							 =     k
    print(__UpperCamelCase      )




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						Tuple       ,     __UpperCamelCase			:						Optional[int]      )  ->							Optional[int]:
    UpperCAmelCase_ ,							UpperCAmelCase_ ,							UpperCAmelCase_							 =     {s: 0}, set(), {s: 0}
    while True:
        if len(__UpperCamelCase      ) == len(__UpperCamelCase      ) - 1:
            break
        UpperCAmelCase_							 =     10_0000
        for i in dist:
            if i not in known and dist[i] < mini:
                UpperCAmelCase_							 =     dist[i]
                UpperCAmelCase_							 =     i
        known.add(__UpperCamelCase      )
        for v in g[u]:
            if v[0] not in known and v[1] < dist.get(v[0]       ,     10_0000      ):
                UpperCAmelCase_							 =     v[1]
                UpperCAmelCase_							 =     u
    return dist




def 					SCREAMING_SNAKE_CASE	(       )  ->							Tuple:
    UpperCAmelCase_ ,							UpperCAmelCase_							 =     map(__UpperCamelCase       ,     input().split(''' '''      )      )
    UpperCAmelCase_							 =     []
    for _ in range(__UpperCamelCase      ):
        edges.append(map(__UpperCamelCase       ,     input().split(''' '''      )      )      )
    return edges, n




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						Tuple      )  ->							Any:
    # Sort edges on the basis of distance
    ((UpperCAmelCase_) ,							(UpperCAmelCase_))							 =     e_and_n
    e.sort(reverse=__UpperCamelCase       ,     key=lambda __UpperCamelCase      : x[2]      )
    UpperCAmelCase_							 =     [{i} for i in range(1       ,     n + 1      )]
    while True:
        if len(__UpperCamelCase      ) == 1:
            break
        print(__UpperCamelCase      )
        UpperCAmelCase_							 =     e.pop()
        for i in range(len(__UpperCamelCase      )      ):
            if x[0] in s[i]:
                break
        for j in range(len(__UpperCamelCase      )      ):
            if x[1] in s[j]:
                if i == j:
                    break
                s[j].update(s[i]      )
                s.pop(__UpperCamelCase      )
                break




def 					SCREAMING_SNAKE_CASE	(       __UpperCamelCase			:						int      )  ->							Tuple:
    UpperCAmelCase_							 =     []
    for node in graph:
        if not graph[node]:
            isolated.append(__UpperCamelCase      )
    return isolated








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


SCREAMING_SNAKE_CASE_						=					{'configuration_hubert': ['HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'HubertConfig']}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE_						=					[
					    'HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'HubertForCTC',
					    'HubertForSequenceClassification',
					    'HubertModel',
					    'HubertPreTrainedModel',
					]


try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE_						=					[
					    'TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'TFHubertForCTC',
					    'TFHubertModel',
					    'TFHubertPreTrainedModel',
					]

if TYPE_CHECKING:
					from .configuration_hubert import HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, HubertConfig

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_hubert import (
										    HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    HubertForCTC,
										    HubertForSequenceClassification,
										    HubertModel,
										    HubertPreTrainedModel,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_hubert import (
										    TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFHubertForCTC,
										    TFHubertModel,
										    TFHubertPreTrainedModel,
										)


else:
					import sys

					SCREAMING_SNAKE_CASE_						=					_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)


