"""simple docstring"""







def   a__      (		UpperCAmelCase__       :			Dict		,			UpperCAmelCase__       :			Union[str, Any]			)->	str:
						UpperCAmelCase__						=		len(lowercase_			)
						UpperCAmelCase__						=		len(lowercase_			)
						UpperCAmelCase__						=		(
						    first_input_list_length
						    if first_input_list_length > second_input_list_length
						    else second_input_list_length
						)
						UpperCAmelCase__						=		[]
						for char_count in range(lowercase_			):
												if char_count < first_input_list_length:
																		output_result_list.append(first_input_list[char_count]			)
												if char_count < second_input_list_length:
																		output_result_list.append(second_input_list[char_count]			)

						return output_result_list


if __name__ == "__main__":
						print(alternative_list_arrange(["""A""", """B""", """C"""], [1, 2, 3, 4, 5]), end=""" """)


"""simple docstring"""







from collections import deque


def   a__      (		UpperCAmelCase__       :			Tuple			)->	Optional[Any]:
						return input(UpperCAmelCase__			).strip().split(""" """			)


def   a__      (		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   a__      (		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   a__      (		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__":
						UpperCamelCase_   ,						UpperCamelCase_       :       Any							   =		(int(i) for i in _input("""Number of nodes and edges: """))

						UpperCamelCase_       :       Union[str, Any]							   =		int(
						    _input(
						        """Press 1 or 2 or 3 \n"""
						        """1. Unweighted directed \n"""
						        """2. Unweighted undirected \n"""
						        """3. Weighted undirected \n"""
						    )[0]
						)

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


def   a__      (		UpperCAmelCase__       :			str		,			UpperCAmelCase__       :			Any			)->	Union[str, Any]:
						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   a__      (		UpperCAmelCase__       :			Union[str, Any]		,			UpperCAmelCase__       :			int			)->	Union[str, Any]:
						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   a__      (		UpperCAmelCase__       :			Optional[Any]		,			UpperCAmelCase__       :			Any			)->	Optional[Any]:
						UpperCAmelCase__	,      UpperCAmelCase__	,      UpperCAmelCase__						=		{s: 0}, set(), {s: 0}
						while True:
												if len(UpperCAmelCase__			) == len(UpperCAmelCase__			) - 1:
																		break
												UpperCAmelCase__						=		1_0_0_0_0_0
												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]		,			1_0_0_0_0_0			):
																								UpperCAmelCase__						=		dist[u] + v[1]
																								UpperCAmelCase__						=		u
						for i in dist:
												if i != s:
																		print(dist[i]			)


def   a__      (		UpperCAmelCase__       :			Any		,			UpperCAmelCase__       :			int=None		,			UpperCAmelCase__       :			List[str]=None			)->	Dict:
						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   a__      (		)->	List[Any]:
						UpperCAmelCase__						=		input().strip()
						UpperCAmelCase__						=		[]
						for _ in range(UpperCAmelCase__			):
												a.append(map(UpperCAmelCase__		,			input().strip().split()			)			)
						return a, n


def   a__      (		UpperCAmelCase__       :			str			)->	str:
						((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   a__      (		UpperCAmelCase__       :			Optional[int]		,			UpperCAmelCase__       :			int			)->	Optional[int]:
						UpperCAmelCase__	,      UpperCAmelCase__	,      UpperCAmelCase__						=		{s: 0}, set(), {s: 0}
						while True:
												if len(UpperCAmelCase__			) == len(UpperCAmelCase__			) - 1:
																		break
												UpperCAmelCase__						=		1_0_0_0_0_0
												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]		,			1_0_0_0_0_0			):
																								UpperCAmelCase__						=		v[1]
																								UpperCAmelCase__						=		u
						return dist


def   a__      (		)->	Union[str, Any]:
						UpperCAmelCase__	,      UpperCAmelCase__						=		map(UpperCAmelCase__		,			input().split(""" """			)			)
						UpperCAmelCase__						=		[]
						for _ in range(UpperCAmelCase__			):
												edges.append(map(UpperCAmelCase__		,			input().split(""" """			)			)			)
						return edges, n


def   a__      (		UpperCAmelCase__       :			Tuple			)->	int:
						# 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   a__      (		UpperCAmelCase__       :			Union[str, Any]			)->	Dict:
						UpperCAmelCase__						=		[]
						for node in graph:
												if not graph[node]:
																		isolated.append(UpperCAmelCase__			)
						return isolated

