
"""simple docstring"""

from collections import deque
def 						UpperCAmelCase   (						a_     ):





		'''simple docstring'''


		return input(_snake_case     ).strip().split(' '     )
def 						UpperCAmelCase   (						a_,		a_     ):





		'''simple docstring'''


		lowerCamelCase	:     Any            =       {}
		for i in range(_snake_case     ):
				lowerCamelCase	:     Union[str, Any]            =       []

		for e in range(_snake_case     ):
				lowerCamelCase      ,       lowerCamelCase	:     List[str]            =       (int(_snake_case     ) for i in _input(F"""Edge {e + 1}: <node1> <node2> """     ))
				graph[x].append(_snake_case     )
		return graph
def 						UpperCAmelCase   (						a_,		a_     ):





		'''simple docstring'''


		lowerCamelCase	:     int            =       {}
		for i in range(_snake_case     ):
				lowerCamelCase	:     Any            =       []

		for e in range(_snake_case     ):
				lowerCamelCase      ,       lowerCamelCase	:     Optional[Any]            =       (int(_snake_case     ) for i in _input(F"""Edge {e + 1}: <node1> <node2> """     ))
				graph[x].append(_snake_case     )
				graph[y].append(_snake_case     )
		return graph
def 						UpperCAmelCase   (						a_,		a_     ):





		'''simple docstring'''


		lowerCamelCase	:     Any            =       {}
		for i in range(_snake_case     ):
				lowerCamelCase	:     int            =       []

		for e in range(_snake_case     ):
				lowerCamelCase      ,       lowerCamelCase      ,       lowerCamelCase	:     str            =       (int(_snake_case     ) 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__":
					_A	,    _A				=					(int(i) for i in _input('Number of nodes and edges: '))

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

					_A				=					{
					    1: initialize_unweighted_directed_graph,
					    2: initialize_unweighted_undirected_graph,
					    3: initialize_weighted_undirected_graph,
					}[graph_choice](n, m)
def 						UpperCAmelCase   (						a_,		a_     ):





		'''simple docstring'''


		lowerCamelCase      ,       lowerCamelCase	:     str            =       {s}, [s]
		print(_snake_case     )
		while _s:
				lowerCamelCase	:     Dict            =       0
				for i in g[_s[-1]]:
						if i not in vis:
								_s.append(_snake_case     )
								vis.add(_snake_case     )
								lowerCamelCase	:     Optional[Any]            =       1
								print(_snake_case     )
								break
				if not flag:
						_s.pop()
def 						UpperCAmelCase   (						a_,		a_     ):





		'''simple docstring'''


		lowerCamelCase      ,       lowerCamelCase	:     List[Any]            =       {s}, deque([s]     )
		print(_snake_case     )
		while q:
				lowerCamelCase	:     Dict            =       q.popleft()
				for v in g[u]:
						if v not in vis:
								vis.add(_snake_case     )
								q.append(_snake_case     )
								print(_snake_case     )
def 						UpperCAmelCase   (						a_,		a_     ):





		'''simple docstring'''


		lowerCamelCase      ,       lowerCamelCase      ,       lowerCamelCase	:     Tuple            =       {s: 0}, set(), {s: 0}
		while True:
				if len(_snake_case     ) == len(_snake_case     ) - 1:
						break
				lowerCamelCase	:     Optional[Any]            =       10_0000
				for i in dist:
						if i not in known and dist[i] < mini:
								lowerCamelCase	:     Optional[Any]            =       dist[i]
								lowerCamelCase	:     List[Any]            =       i
				known.add(_snake_case     )
				for v in g[u]:
						if v[0] not in known and dist[u] + v[1] < dist.get(v[0],		10_0000     ):
								lowerCamelCase	:     List[Any]            =       dist[u] + v[1]
								lowerCamelCase	:     List[Any]            =       u
		for i in dist:
				if i != s:
						print(dist[i]     )
def 						UpperCAmelCase   (						a_,		a_=None,		a_=None     ):





		'''simple docstring'''


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





		'''simple docstring'''


		lowerCamelCase	:     List[Any]            =       input().strip()
		lowerCamelCase	:     List[str]            =       []
		for _ in range(_snake_case     ):
				a.append(map(_snake_case,		input().strip().split()     )     )
		return a, n
def 						UpperCAmelCase   (						a_     ):





		'''simple docstring'''


		((lowerCamelCase)      ,       (lowerCamelCase))	:     int            =       a_and_n
		lowerCamelCase	:     Dict            =       list(_snake_case     )
		lowerCamelCase	:     Optional[Any]            =       [[0] * n for i in range(_snake_case     )]
		for k in range(_snake_case     ):
				for i in range(_snake_case     ):
						for j in range(_snake_case     ):
								if dist[i][j] > dist[i][k] + dist[k][j]:
										lowerCamelCase	:     str            =       dist[i][k] + dist[k][j]
										lowerCamelCase	:     Union[str, Any]            =       k
		print(_snake_case     )
def 						UpperCAmelCase   (						a_,		a_     ):





		'''simple docstring'''


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





		'''simple docstring'''


		lowerCamelCase      ,       lowerCamelCase	:     str            =       map(_snake_case,		input().split(' '     )     )
		lowerCamelCase	:     Optional[int]            =       []
		for _ in range(_snake_case     ):
				edges.append(map(_snake_case,		input().split(' '     )     )     )
		return edges, n
def 						UpperCAmelCase   (						a_     ):





		'''simple docstring'''


		((lowerCamelCase)      ,       (lowerCamelCase))	:     Union[str, Any]            =       e_and_n
		e.sort(reverse=_snake_case,		key=lambda a_     : x[2]     )
		lowerCamelCase	:     int            =       [{i} for i in range(1,		n + 1     )]
		while True:
				if len(_snake_case     ) == 1:
						break
				print(_snake_case     )
				lowerCamelCase	:     Optional[int]            =       e.pop()
				for i in range(len(_snake_case     )     ):
						if x[0] in s[i]:
								break
				for j in range(len(_snake_case     )     ):
						if x[1] in s[j]:
								if i == j:
										break
								s[j].update(s[i]     )
								s.pop(_snake_case     )
								break





def 						UpperCAmelCase   (						a_     ):





		'''simple docstring'''


		lowerCamelCase	:     int            =       []
		for node in graph:
				if not graph[node]:
						isolated.append(_snake_case     )
		return isolated












from typing import TYPE_CHECKING

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


UpperCAmelCase_    ={
    """configuration_splinter""": ["""SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SplinterConfig"""],
    """tokenization_splinter""": ["""SplinterTokenizer"""],
}

try:
		if not is_tokenizers_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		UpperCAmelCase_    =["""SplinterTokenizerFast"""]

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		UpperCAmelCase_    =[
		    """SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST""",
		    """SplinterForQuestionAnswering""",
		    """SplinterForPreTraining""",
		    """SplinterLayer""",
		    """SplinterModel""",
		    """SplinterPreTrainedModel""",
		]


if TYPE_CHECKING:
		from .configuration_splinter import SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP, SplinterConfig
		from .tokenization_splinter import SplinterTokenizer

		try:
				if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_splinter_fast import SplinterTokenizerFast

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_splinter import (
				    SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST,
				    SplinterForPreTraining,
				    SplinterForQuestionAnswering,
				    SplinterLayer,
				    SplinterModel,
				    SplinterPreTrainedModel,
				)


else:
		import sys

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



