


from collections import deque







def     __magic_name__  (      lowerCAmelCase_):
	'''simple docstring'''


	return input(lowerCAmelCase_).strip().split(" ")







def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_			:							dict[int, list[int]]      =       {}
	for i in range(lowerCAmelCase_):
		lowerCamelCase_			:							Optional[int]      =       []

	for e in range(lowerCAmelCase_):
		lowerCamelCase_   ,lowerCamelCase_			:							List[Any]      =       (int(lowerCAmelCase_) for i in _input(F"""Edge {e + 1}: <node1> <node2> """))
		graph[x].append(lowerCAmelCase_)
	return graph







def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_			:							dict[int, list[int]]      =       {}
	for i in range(lowerCAmelCase_):
		lowerCamelCase_			:							int      =       []

	for e in range(lowerCAmelCase_):
		lowerCamelCase_   ,lowerCamelCase_			:							str      =       (int(lowerCAmelCase_) for i in _input(F"""Edge {e + 1}: <node1> <node2> """))
		graph[x].append(lowerCAmelCase_)
		graph[y].append(lowerCAmelCase_)
	return graph







def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_			:							dict[int, list[tuple[int, int]]]      =       {}
	for i in range(lowerCAmelCase_):
		lowerCamelCase_			:							Any      =       []

	for e in range(lowerCAmelCase_):
		lowerCamelCase_   ,lowerCamelCase_   ,lowerCamelCase_			:							Optional[Any]      =       (int(lowerCAmelCase_) 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__":
							__magic_name__					,      __magic_name__       					=      (int(i) for i in _input('''Number of nodes and edges: '''))

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

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







def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_):
	'''simple docstring'''


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







def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_   ,lowerCamelCase_			:							Tuple      =       {s}, deque([s])
	print(lowerCAmelCase_)
	while q:
		lowerCamelCase_			:							List[str]      =       q.popleft()
		for v in g[u]:
			if v not in vis:
				vis.add(lowerCAmelCase_)
				q.append(lowerCAmelCase_)
				print(lowerCAmelCase_)







def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_   ,lowerCamelCase_   ,lowerCamelCase_			:							Any      =       {s: 0}, set(), {s: 0}
	while True:
		if len(lowerCAmelCase_) == len(lowerCAmelCase_) - 1:
			break
		lowerCamelCase_			:							Tuple      =       10_0000
		for i in dist:
			if i not in known and dist[i] < mini:
				lowerCamelCase_			:							Union[str, Any]      =       dist[i]
				lowerCamelCase_			:							Any      =       i
		known.add(lowerCAmelCase_)
		for v in g[u]:
			if v[0] not in known and dist[u] + v[1] < dist.get(v[0]      ,					10_0000):
				lowerCamelCase_			:							Optional[Any]      =       dist[u] + v[1]
				lowerCamelCase_			:							int      =       u
	for i in dist:
		if i != s:
			print(dist[i])







def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_=None      ,					lowerCAmelCase_=None):
	'''simple docstring'''


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







def     __magic_name__  (      ):
	'''simple docstring'''


	lowerCamelCase_			:							Union[str, Any]      =       input().strip()
	lowerCamelCase_			:							Optional[Any]      =       []
	for _ in range(lowerCAmelCase_):
		a.append(map(lowerCAmelCase_      ,					input().strip().split()))
	return a, n







def     __magic_name__  (      lowerCAmelCase_):
	'''simple docstring'''


	((lowerCamelCase_)   ,(lowerCamelCase_))			:							int      =       a_and_n
	lowerCamelCase_			:							Optional[int]      =       list(lowerCAmelCase_)
	lowerCamelCase_			:							List[Any]      =       [[0] * n for i in range(lowerCAmelCase_)]
	for k in range(lowerCAmelCase_):
		for i in range(lowerCAmelCase_):
			for j in range(lowerCAmelCase_):
				if dist[i][j] > dist[i][k] + dist[k][j]:
					lowerCamelCase_			:							List[Any]      =       dist[i][k] + dist[k][j]
					lowerCamelCase_			:							int      =       k
	print(lowerCAmelCase_)







def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_   ,lowerCamelCase_   ,lowerCamelCase_			:							Union[str, Any]      =       {s: 0}, set(), {s: 0}
	while True:
		if len(lowerCAmelCase_) == len(lowerCAmelCase_) - 1:
			break
		lowerCamelCase_			:							List[str]      =       10_0000
		for i in dist:
			if i not in known and dist[i] < mini:
				lowerCamelCase_			:							Any      =       dist[i]
				lowerCamelCase_			:							int      =       i
		known.add(lowerCAmelCase_)
		for v in g[u]:
			if v[0] not in known and v[1] < dist.get(v[0]      ,					10_0000):
				lowerCamelCase_			:							Union[str, Any]      =       v[1]
				lowerCamelCase_			:							Union[str, Any]      =       u
	return dist







def     __magic_name__  (      ):
	'''simple docstring'''


	lowerCamelCase_   ,lowerCamelCase_			:							Any      =       map(lowerCAmelCase_      ,					input().split(" "))
	lowerCamelCase_			:							Dict      =       []
	for _ in range(lowerCAmelCase_):
		edges.append(map(lowerCAmelCase_      ,					input().split(" ")))
	return edges, n







def     __magic_name__  (      lowerCAmelCase_):
	'''simple docstring'''


	((lowerCamelCase_)   ,(lowerCamelCase_))			:							Dict      =       e_and_n
	e.sort(reverse=lowerCAmelCase_      ,					key=lambda lowerCAmelCase_: x[2])
	lowerCamelCase_			:							List[Any]      =       [{i} for i in range(1      ,					n + 1)]
	while True:
		if len(lowerCAmelCase_) == 1:
			break
		print(lowerCAmelCase_)
		lowerCamelCase_			:							List[str]      =       e.pop()
		for i in range(len(lowerCAmelCase_)):
			if x[0] in s[i]:
				break
		for j in range(len(lowerCAmelCase_)):
			if x[1] in s[j]:
				if i == j:
					break
				s[j].update(s[i])
				s.pop(lowerCAmelCase_)
				break







def     __magic_name__  (      lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_			:							str      =       []
	for node in graph:
		if not graph[node]:
			isolated.append(lowerCAmelCase_)
	return isolated





from typing import TYPE_CHECKING

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


__magic_name__       					=      {'''configuration_detr''': ['''DETR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DetrConfig''', '''DetrOnnxConfig''']}

try:
							if not is_vision_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__magic_name__       					=      ['''DetrFeatureExtractor''']
							__magic_name__       					=      ['''DetrImageProcessor''']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__magic_name__       					=      [
							    '''DETR_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''DetrForObjectDetection''',
							    '''DetrForSegmentation''',
							    '''DetrModel''',
							    '''DetrPreTrainedModel''',
							]


if TYPE_CHECKING:
							from .configuration_detr import DETR_PRETRAINED_CONFIG_ARCHIVE_MAP, DetrConfig, DetrOnnxConfig

							try:
														if not is_vision_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .feature_extraction_detr import DetrFeatureExtractor
														from .image_processing_detr import DetrImageProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_detr import (
														    DETR_PRETRAINED_MODEL_ARCHIVE_LIST,
														    DetrForObjectDetection,
														    DetrForSegmentation,
														    DetrModel,
														    DetrPreTrainedModel,
														)

else:
							import sys

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

