





'''simple docstring'''







from collections import deque





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      Any )			->						List[Any]:
						return input(SCREAMING_SNAKE_CASE__ ).strip().split(''' ''' )





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      int,      SCREAMING_SNAKE_CASE__   :      int )			->						dict[int, list[int]]:
						UpperCAmelCase_      :   dict[int, list[int]]      =	{}
						for i in range(SCREAMING_SNAKE_CASE__ ):
												UpperCAmelCase_      :   Optional[Any]      =	[]

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





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

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





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

						for e in range(SCREAMING_SNAKE_CASE__ ):
												UpperCAmelCase_    ,							UpperCAmelCase_    ,							UpperCAmelCase_      :   Tuple      =	(int(SCREAMING_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__":
					snake_case_      ,snake_case_  :							Optional[int]            =	(int(i) for i in _input("Number of nodes and edges: "))

					snake_case_  :							Tuple            =	int(
					    _input(
					        "Press 1 or 2 or 3 \n"
					        "1. Unweighted directed \n"
					        "2. Unweighted undirected \n"
					        "3. Weighted undirected \n"
					    )[0]
					)

					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 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      List[str],      SCREAMING_SNAKE_CASE__   :      Optional[Any] )			->						List[Any]:
						UpperCAmelCase_    ,							UpperCAmelCase_      :   Optional[int]      =	{s}, [s]
						print(SCREAMING_SNAKE_CASE__ )
						while _s:
												UpperCAmelCase_      :   Optional[int]      =	0
												for i in g[_s[-1]]:
																		if i not in vis:
																								_s.append(SCREAMING_SNAKE_CASE__ )
																								vis.add(SCREAMING_SNAKE_CASE__ )
																								UpperCAmelCase_      :   List[Any]      =	1
																								print(SCREAMING_SNAKE_CASE__ )
																								break
												if not flag:
																		_s.pop()





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





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      Dict,      SCREAMING_SNAKE_CASE__   :      List[Any] )			->						Optional[int]:
						UpperCAmelCase_    ,							UpperCAmelCase_    ,							UpperCAmelCase_      :   List[str]      =	{s: 0}, set(), {s: 0}
						while True:
												if len(SCREAMING_SNAKE_CASE__ ) == len(SCREAMING_SNAKE_CASE__ ) - 1:
																		break
												UpperCAmelCase_      :   str      =	100000
												for i in dist:
																		if i not in known and dist[i] < mini:
																								UpperCAmelCase_      :   List[str]      =	dist[i]
																								UpperCAmelCase_      :   Optional[Any]      =	i
												known.add(SCREAMING_SNAKE_CASE__ )
												for v in g[u]:
																		if v[0] not in known and dist[u] + v[1] < dist.get(v[0],      100000 ):
																								UpperCAmelCase_      :   Any      =	dist[u] + v[1]
																								UpperCAmelCase_      :   Tuple      =	u
						for i in dist:
												if i != s:
																		print(dist[i] )





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





def 							lowerCamelCase_   (	)			->						List[str]:
						UpperCAmelCase_      :   Union[str, Any]      =	input().strip()
						UpperCAmelCase_      :   int      =	[]
						for _ in range(SCREAMING_SNAKE_CASE__ ):
												a.append(map(SCREAMING_SNAKE_CASE__,      input().strip().split() ) )
						return a, n





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      Union[str, Any] )			->						Tuple:
						((UpperCAmelCase_)    ,							(UpperCAmelCase_))      :   Union[str, Any]      =	a_and_n
						UpperCAmelCase_      :   int      =	list(SCREAMING_SNAKE_CASE__ )
						UpperCAmelCase_      :   Tuple      =	[[0] * n for i in range(SCREAMING_SNAKE_CASE__ )]
						for k in range(SCREAMING_SNAKE_CASE__ ):
												for i in range(SCREAMING_SNAKE_CASE__ ):
																		for j in range(SCREAMING_SNAKE_CASE__ ):
																								if dist[i][j] > dist[i][k] + dist[k][j]:
																														UpperCAmelCase_      :   Tuple      =	dist[i][k] + dist[k][j]
																														UpperCAmelCase_      :   Union[str, Any]      =	k
						print(SCREAMING_SNAKE_CASE__ )





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





def 							lowerCamelCase_   (	)			->						int:
						UpperCAmelCase_    ,							UpperCAmelCase_      :   Any      =	map(SCREAMING_SNAKE_CASE__,      input().split(''' ''' ) )
						UpperCAmelCase_      :   List[str]      =	[]
						for _ in range(SCREAMING_SNAKE_CASE__ ):
												edges.append(map(SCREAMING_SNAKE_CASE__,      input().split(''' ''' ) ) )
						return edges, n





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





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      List[Any] )			->						Any:
						UpperCAmelCase_      :   str      =	[]
						for node in graph:
												if not graph[node]:
																		isolated.append(SCREAMING_SNAKE_CASE__ )
						return isolated












'''simple docstring'''







import argparse
import json
import re
import string
import sys
from collections import Counter





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      Optional[Any] )			->						str:

						def remove_articles(SCREAMING_SNAKE_CASE__   :      Union[str, Any] ):
												return re.sub(R'''\b(a|an|the)\b''',      ''' ''',      SCREAMING_SNAKE_CASE__ )

						def white_space_fix(SCREAMING_SNAKE_CASE__   :      Dict ):
												return " ".join(text.split() )

						def remove_punc(SCREAMING_SNAKE_CASE__   :      Union[str, Any] ):
												UpperCAmelCase_      :   int      =	set(string.punctuation )
												return "".join(ch for ch in text if ch not in exclude )

						def lower(SCREAMING_SNAKE_CASE__   :      str ):
												return text.lower()

						return white_space_fix(remove_articles(remove_punc(lower(SCREAMING_SNAKE_CASE__ ) ) ) )





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      Union[str, Any],      SCREAMING_SNAKE_CASE__   :      Union[str, Any] )			->						Tuple:
						UpperCAmelCase_      :   List[Any]      =	normalize_answer(SCREAMING_SNAKE_CASE__ ).split()
						UpperCAmelCase_      :   Optional[Any]      =	normalize_answer(SCREAMING_SNAKE_CASE__ ).split()
						UpperCAmelCase_      :   Any      =	Counter(SCREAMING_SNAKE_CASE__ ) & Counter(SCREAMING_SNAKE_CASE__ )
						UpperCAmelCase_      :   Tuple      =	sum(common.values() )
						if num_same == 0:
												return 0
						UpperCAmelCase_      :   Union[str, Any]      =	1.0 * num_same / len(SCREAMING_SNAKE_CASE__ )
						UpperCAmelCase_      :   Dict      =	1.0 * num_same / len(SCREAMING_SNAKE_CASE__ )
						UpperCAmelCase_      :   str      =	(2 * precision * recall) / (precision + recall)
						return fa





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      int,      SCREAMING_SNAKE_CASE__   :      int )			->						Any:
						return normalize_answer(SCREAMING_SNAKE_CASE__ ) == normalize_answer(SCREAMING_SNAKE_CASE__ )





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      Union[str, Any],      SCREAMING_SNAKE_CASE__   :      Any,      SCREAMING_SNAKE_CASE__   :      Dict )			->						Optional[int]:
						UpperCAmelCase_      :   Dict      =	[]
						for ground_truth in ground_truths:
												UpperCAmelCase_      :   str      =	metric_fn(SCREAMING_SNAKE_CASE__,      SCREAMING_SNAKE_CASE__ )
												scores_for_ground_truths.append(SCREAMING_SNAKE_CASE__ )
						return max(SCREAMING_SNAKE_CASE__ )





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      List[str],      SCREAMING_SNAKE_CASE__   :      Optional[Any] )			->						Any:
						UpperCAmelCase_      :   str      =	0
						for article in dataset:
												for paragraph in article["paragraphs"]:
																		for qa in paragraph["qas"]:
																								total += 1
																								if qa["id"] not in predictions:
																														UpperCAmelCase_      :   Union[str, Any]      =	'''Unanswered question ''' + qa['''id'''] + ''' will receive score 0.'''
																														print(SCREAMING_SNAKE_CASE__,      file=sys.stderr )
																														continue
																								UpperCAmelCase_      :   Optional[Any]      =	[x['''text'''] for x in qa['''answers''']]
																								UpperCAmelCase_      :   int      =	predictions[qa['''id''']]
																								exact_match += metric_max_over_ground_truths(SCREAMING_SNAKE_CASE__,      SCREAMING_SNAKE_CASE__,      SCREAMING_SNAKE_CASE__ )
																								fa += metric_max_over_ground_truths(SCREAMING_SNAKE_CASE__,      SCREAMING_SNAKE_CASE__,      SCREAMING_SNAKE_CASE__ )

						UpperCAmelCase_      :   Any      =	1_00.0 * exact_match / total
						UpperCAmelCase_      :   Optional[int]      =	1_00.0 * fa / total

						return {"exact_match": exact_match, "f1": fa}


if __name__ == "__main__":
					snake_case_  :							Any            =	"1.1"
					snake_case_  :							Any            =	argparse.ArgumentParser(description="Evaluation for SQuAD " + expected_version)
					parser.add_argument("dataset_file", help="Dataset file")
					parser.add_argument("prediction_file", help="Prediction File")
					snake_case_  :							int            =	parser.parse_args()
					with open(args.dataset_file) as dataset_file:
										snake_case_  :							List[Any]            =	json.load(dataset_file)
										if dataset_json["version"] != expected_version:
															print(
															    "Evaluation expects v-" + expected_version + ", but got dataset with v-" + dataset_json["version"],
															    file=sys.stderr,
															)
										snake_case_  :							Tuple            =	dataset_json["data"]
					with open(args.prediction_file) as prediction_file:
										snake_case_  :							Tuple            =	json.load(prediction_file)
					print(json.dumps(evaluate(dataset, predictions)))





