
from collections import deque
def     UpperCAmelCase__							(       __magic_name__						:     Tuple  ):


					'''simple docstring'''

					return input(__magic_name__  ).strip().split(''' '''  )
def     UpperCAmelCase__							(       __magic_name__						:     int							,  __magic_name__						:     int  ):


					'''simple docstring'''

					lowerCAmelCase		:					dict[int, list[int]]  	=     {}
					for i in range(__magic_name__  ):
										lowerCAmelCase		:					Union[str, Any]  	=     []

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


					'''simple docstring'''

					lowerCAmelCase		:					dict[int, list[int]]  	=     {}
					for i in range(__magic_name__  ):
										lowerCAmelCase		:					Tuple  	=     []

					for e in range(__magic_name__  ):
										lowerCAmelCase	,							lowerCAmelCase		:					Union[str, Any]  	=     (int(__magic_name__  ) for i in _input(f'''Edge {e + 1}: <node1> <node2> '''  ))
										graph[x].append(__magic_name__  )
										graph[y].append(__magic_name__  )
					return graph
def     UpperCAmelCase__							(       __magic_name__						:     int							,  __magic_name__						:     int  ):


					'''simple docstring'''

					lowerCAmelCase		:					dict[int, list[tuple[int, int]]]  	=     {}
					for i in range(__magic_name__  ):
										lowerCAmelCase		:					int  	=     []

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

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

		__SCREAMING_SNAKE_CASE			:   Union[str, Any]         =     {
		    1: initialize_unweighted_directed_graph,
		    2: initialize_unweighted_undirected_graph,
		    3: initialize_weighted_undirected_graph,
		}[graph_choice](n, m)
def     UpperCAmelCase__							(       __magic_name__						:     Tuple							,  __magic_name__						:     List[Any]  ):


					'''simple docstring'''

					lowerCAmelCase	,							lowerCAmelCase		:					str  	=     {s}, [s]
					print(__magic_name__  )
					while _s:
										lowerCAmelCase		:					Any  	=     0
										for i in g[_s[-1]]:
															if i not in vis:
																				_s.append(__magic_name__  )
																				vis.add(__magic_name__  )
																				lowerCAmelCase		:					Union[str, Any]  	=     1
																				print(__magic_name__  )
																				break
										if not flag:
															_s.pop()
def     UpperCAmelCase__							(       __magic_name__						:     List[Any]							,  __magic_name__						:     List[str]  ):


					'''simple docstring'''

					lowerCAmelCase	,							lowerCAmelCase		:					Any  	=     {s}, deque([s]  )
					print(__magic_name__  )
					while q:
										lowerCAmelCase		:					List[str]  	=     q.popleft()
										for v in g[u]:
															if v not in vis:
																				vis.add(__magic_name__  )
																				q.append(__magic_name__  )
																				print(__magic_name__  )
def     UpperCAmelCase__							(       __magic_name__						:     Optional[Any]							,  __magic_name__						:     str  ):


					'''simple docstring'''

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


					'''simple docstring'''

					if q is None:
										lowerCAmelCase		:					List[Any]  	=     [1]
					if ind is None:
										lowerCAmelCase		:					Optional[Any]  	=     [0] * (len(__magic_name__  ) + 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(__magic_name__  )
					if len(__magic_name__  ) == 0:
										return
					lowerCAmelCase		:					Any  	=     q.popleft()
					print(__magic_name__  )
					for w in g[v]:
										ind[w] -= 1
										if ind[w] == 0:
															q.append(__magic_name__  )
					topo(__magic_name__							,  __magic_name__							,  __magic_name__  )
def     UpperCAmelCase__							(       ):


					'''simple docstring'''

					lowerCAmelCase		:					Optional[Any]  	=     input().strip()
					lowerCAmelCase		:					Optional[Any]  	=     []
					for _ in range(__magic_name__  ):
										a.append(map(__magic_name__							,  input().strip().split()  )  )
					return a, n
def     UpperCAmelCase__							(       __magic_name__						:     Tuple  ):


					'''simple docstring'''

					((lowerCAmelCase)	,							(lowerCAmelCase))		:					str  	=     a_and_n
					lowerCAmelCase		:					Tuple  	=     list(__magic_name__  )
					lowerCAmelCase		:					List[str]  	=     [[0] * n for i in range(__magic_name__  )]
					for k in range(__magic_name__  ):
										for i in range(__magic_name__  ):
															for j in range(__magic_name__  ):
																				if dist[i][j] > dist[i][k] + dist[k][j]:
																									lowerCAmelCase		:					Optional[Any]  	=     dist[i][k] + dist[k][j]
																									lowerCAmelCase		:					Dict  	=     k
					print(__magic_name__  )
def     UpperCAmelCase__							(       __magic_name__						:     Dict							,  __magic_name__						:     Optional[int]  ):


					'''simple docstring'''

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


					'''simple docstring'''

					lowerCAmelCase	,							lowerCAmelCase		:					List[str]  	=     map(__magic_name__							,  input().split(''' '''  )  )
					lowerCAmelCase		:					str  	=     []
					for _ in range(__magic_name__  ):
										edges.append(map(__magic_name__							,  input().split(''' '''  )  )  )
					return edges, n
def     UpperCAmelCase__							(       __magic_name__						:     List[Any]  ):


					'''simple docstring'''

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


					'''simple docstring'''

					lowerCAmelCase		:					Optional[Any]  	=     []
					for node in graph:
										if not graph[node]:
															isolated.append(__magic_name__  )
					return isolated


from typing import TYPE_CHECKING

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


__SCREAMING_SNAKE_CASE			:   List[str]         =     {'configuration_vilt': ['VILT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViltConfig']}

try:
		if not is_vision_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__SCREAMING_SNAKE_CASE			:   Any         =     ['ViltFeatureExtractor']
		__SCREAMING_SNAKE_CASE			:   Optional[int]         =     ['ViltImageProcessor']
		__SCREAMING_SNAKE_CASE			:   str         =     ['ViltProcessor']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__SCREAMING_SNAKE_CASE			:   Dict         =     [
		    'VILT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'ViltForImageAndTextRetrieval',
		    'ViltForImagesAndTextClassification',
		    'ViltForTokenClassification',
		    'ViltForMaskedLM',
		    'ViltForQuestionAnswering',
		    'ViltLayer',
		    'ViltModel',
		    'ViltPreTrainedModel',
		]


if TYPE_CHECKING:
		from .configuration_vilt import VILT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViltConfig

		try:
				if not is_vision_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .feature_extraction_vilt import ViltFeatureExtractor
				from .image_processing_vilt import ViltImageProcessor
				from .processing_vilt import ViltProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_vilt import (
				    VILT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    ViltForImageAndTextRetrieval,
				    ViltForImagesAndTextClassification,
				    ViltForMaskedLM,
				    ViltForQuestionAnswering,
				    ViltForTokenClassification,
				    ViltLayer,
				    ViltModel,
				    ViltPreTrainedModel,
				)


else:
		import sys

		__SCREAMING_SNAKE_CASE			:   Optional[Any]         =     _LazyModule(__name__, globals()['__file__'], _import_structure)
