



'''simple docstring'''





from collections import deque

def 	a_					(							_lowerCAmelCase	)				->				Tuple:
  return input(_lowerCAmelCase	).strip().split(' '	)

def 	a_					(							_lowerCAmelCase	,_lowerCAmelCase	)				->				dict[int, list[int]]:
  __lowerCamelCase	:	dict[int, list[int]]   	=			{}
  for i in range(_lowerCAmelCase	):
    __lowerCamelCase	:	int   	=			[]

  for e in range(_lowerCAmelCase	):
    __lowerCamelCase	,__lowerCamelCase	:	Tuple   	=			(int(_lowerCAmelCase	) for i in _input(F'Edge {e + 1}: <node1> <node2> '	))
    graph[x].append(_lowerCAmelCase	)
  return graph

def 	a_					(							_lowerCAmelCase	,_lowerCAmelCase	)				->				dict[int, list[int]]:
  __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	)
    graph[y].append(_lowerCAmelCase	)
  return graph

def 	a_					(							_lowerCAmelCase	,_lowerCAmelCase	)				->				dict[int, list[tuple[int, int]]]:
  __lowerCamelCase	:	dict[int, list[tuple[int, int]]]   	=			{}
  for i in range(_lowerCAmelCase	):
    __lowerCamelCase	:	Union[str, 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__":
   _UpperCamelCase    ,    _UpperCamelCase							    =						(int(i) for i in _input('Number of nodes and edges: '))

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

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

def 	a_					(							_lowerCAmelCase	,_lowerCAmelCase	)				->				List[Any]:
  __lowerCamelCase	,__lowerCamelCase	:	str   	=			{s}, [s]
  print(_lowerCAmelCase	)
  while _s:
    __lowerCamelCase	:	Optional[int]   	=			0
    for i in g[_s[-1]]:
      if i not in vis:
        _s.append(_lowerCAmelCase	)
        vis.add(_lowerCAmelCase	)
        __lowerCamelCase	:	str   	=			1
        print(_lowerCAmelCase	)
        break
    if not flag:
      _s.pop()

def 	a_					(							_lowerCAmelCase	,_lowerCAmelCase	)				->				Union[str, Any]:
  __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 	a_					(							_lowerCAmelCase	,_lowerCAmelCase	)				->				Optional[int]:
  __lowerCamelCase	,__lowerCamelCase	,__lowerCamelCase	:	List[str]   	=			{s: 0}, set(), {s: 0}
  while True:
    if len(_lowerCAmelCase	) == len(_lowerCAmelCase	) - 1:
      break
    __lowerCamelCase	:	List[Any]   	=			100000
    for i in dist:
      if i not in known and dist[i] < mini:
        __lowerCamelCase	:	str   	=			dist[i]
        __lowerCamelCase	:	List[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]	,100000	):
        __lowerCamelCase	:	List[str]   	=			dist[u] + v[1]
        __lowerCamelCase	:	Any   	=			u
  for i in dist:
    if i != s:
      print(dist[i]	)

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

def 	a_					(							)				->				Optional[Any]:
  __lowerCamelCase	:	List[Any]   	=			input().strip()
  __lowerCamelCase	:	Any   	=			[]
  for _ in range(_lowerCAmelCase	):
    a.append(map(_lowerCAmelCase	,input().strip().split()	)	)
  return a, n

def 	a_					(							_lowerCAmelCase	)				->				Tuple:
  ((__lowerCamelCase)	,(__lowerCamelCase))	:	List[str]   	=			a_and_n
  __lowerCamelCase	:	Optional[Any]   	=			list(_lowerCAmelCase	)
  __lowerCamelCase	:	List[str]   	=			[[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[str]   	=			dist[i][k] + dist[k][j]
          __lowerCamelCase	:	Optional[int]   	=			k
  print(_lowerCAmelCase	)

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

def 	a_					(							)				->				Union[str, Any]:
  __lowerCamelCase	,__lowerCamelCase	:	Optional[int]   	=			map(_lowerCAmelCase	,input().split(' '	)	)
  __lowerCamelCase	:	Union[str, Any]   	=			[]
  for _ in range(_lowerCAmelCase	):
    edges.append(map(_lowerCAmelCase	,input().split(' '	)	)	)
  return edges, n

def 	a_					(							_lowerCAmelCase	)				->				int:
  # Sort edges on the basis of distance
  ((__lowerCamelCase)	,(__lowerCamelCase))	:	Any   	=			e_and_n
  e.sort(reverse=_lowerCAmelCase	,key=lambda _lowerCAmelCase	: x[2]	)
  __lowerCamelCase	:	Optional[int]   	=			[{i} for i in range(1	,n + 1	)]
  while True:
    if len(_lowerCAmelCase	) == 1:
      break
    print(_lowerCAmelCase	)
    __lowerCamelCase	:	Optional[Any]   	=			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 	a_					(							_lowerCAmelCase	)				->				Dict:
  __lowerCamelCase	:	Any   	=			[]
  for node in graph:
    if not graph[node]:
      isolated.append(_lowerCAmelCase	)
  return isolated











'''simple docstring'''





from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

# Load iris file
_UpperCamelCase							    =						load_iris()
iris.keys()


print(f'''Target names: \n {iris.target_names} ''')
print(f'''\n Features: \n {iris.feature_names}''')

# Train set e Test set
_UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase							    =						train_test_split(
    iris['data'], iris['target'], random_state=4
)

# KNN

_UpperCamelCase							    =						KNeighborsClassifier(n_neighbors=1)
knn.fit(X_train, y_train)

# new array to test
_UpperCamelCase							    =						[[1, 2, 1, 4], [2, 3, 4, 5]]

_UpperCamelCase							    =						knn.predict(X_new)

print(
    f'''\nNew array: \n {X_new}\n\nTarget Names Prediction: \n'''
    f''' {iris["target_names"][prediction]}'''
)






