


'''simple docstring'''




from collections import deque





def      _a		(lowercase__ :      Union[str, Any]	) -> Optional[int]:






     """simple docstring"""
     return input(lowercase__	).strip().split(' '	)





def      _a		(lowercase__ :      int       ,      lowercase__ :      int	) -> dict[int, list[int]]:






     """simple docstring"""
     __snake_case    			=	{}
     for i in range(lowercase__	):
          __snake_case    			=	[]

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





def      _a		(lowercase__ :      int       ,      lowercase__ :      int	) -> dict[int, list[int]]:






     """simple docstring"""
     __snake_case    			=	{}
     for i in range(lowercase__	):
          __snake_case    			=	[]

     for e in range(lowercase__	):
          __snake_case			,					__snake_case    			=	(int(lowercase__	) for i in _input(f'Edge {e + 1}: <node1> <node2> '	))
          graph[x].append(lowercase__	)
          graph[y].append(lowercase__	)
     return graph





def      _a		(lowercase__ :      int       ,      lowercase__ :      int	) -> dict[int, list[tuple[int, int]]]:






     """simple docstring"""
     __snake_case    			=	{}
     for i in range(lowercase__	):
          __snake_case    			=	[]

     for e in range(lowercase__	):
          __snake_case			,					__snake_case			,					__snake_case    			=	(int(lowercase__	) 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      :      str       				=      (int(i) for i in _input("Number of nodes and edges: "))

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

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





def      _a		(lowercase__ :      Dict       ,      lowercase__ :      Union[str, Any]	) -> Optional[int]:






     """simple docstring"""
     __snake_case			,					__snake_case    			=	{s}, [s]
     print(lowercase__	)
     while _s:
          __snake_case    			=	0
          for i in g[_s[-1]]:
               if i not in vis:
                    _s.append(lowercase__	)
                    vis.add(lowercase__	)
                    __snake_case    			=	1
                    print(lowercase__	)
                    break
          if not flag:
               _s.pop()





def      _a		(lowercase__ :      Any       ,      lowercase__ :      int	) -> Tuple:






     """simple docstring"""
     __snake_case			,					__snake_case    			=	{s}, deque([s]	)
     print(lowercase__	)
     while q:
          __snake_case    			=	q.popleft()
          for v in g[u]:
               if v not in vis:
                    vis.add(lowercase__	)
                    q.append(lowercase__	)
                    print(lowercase__	)





def      _a		(lowercase__ :      Tuple       ,      lowercase__ :      List[str]	) -> Dict:






     """simple docstring"""
     __snake_case			,					__snake_case			,					__snake_case    			=	{s: 0}, set(), {s: 0}
     while True:
          if len(lowercase__	) == len(lowercase__	) - 1:
               break
          __snake_case    			=	1_0_0_0_0_0
          for i in dist:
               if i not in known and dist[i] < mini:
                    __snake_case    			=	dist[i]
                    __snake_case    			=	i
          known.add(lowercase__	)
          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	):
                    __snake_case    			=	dist[u] + v[1]
                    __snake_case    			=	u
     for i in dist:
          if i != s:
               print(dist[i]	)





def      _a		(lowercase__ :      int       ,      lowercase__ :      Tuple=None       ,      lowercase__ :      Dict=None	) -> str:






     """simple docstring"""
     if q is None:
          __snake_case    			=	[1]
     if ind is None:
          __snake_case    			=	[0] * (len(lowercase__	) + 1)  # SInce oth Index is ignored
          for u in g:
               for v in g[u]:
                    ind[v] += 1
          __snake_case    			=	deque()
          for i in g:
               if ind[i] == 0:
                    q.append(lowercase__	)
     if len(lowercase__	) == 0:
          return
     __snake_case    			=	q.popleft()
     print(lowercase__	)
     for w in g[v]:
          ind[w] -= 1
          if ind[w] == 0:
               q.append(lowercase__	)
     topo(lowercase__       ,      lowercase__       ,      lowercase__	)





def      _a		() -> List[str]:






     """simple docstring"""
     __snake_case    			=	input().strip()
     __snake_case    			=	[]
     for _ in range(lowercase__	):
          a.append(map(lowercase__       ,      input().strip().split()	)	)
     return a, n





def      _a		(lowercase__ :      Optional[int]	) -> str:






     """simple docstring"""
     ((__snake_case)			,					(__snake_case))    			=	a_and_n
     __snake_case    			=	list(lowercase__	)
     __snake_case    			=	[[0] * n for i in range(lowercase__	)]
     for k in range(lowercase__	):
          for i in range(lowercase__	):
               for j in range(lowercase__	):
                    if dist[i][j] > dist[i][k] + dist[k][j]:
                         __snake_case    			=	dist[i][k] + dist[k][j]
                         __snake_case    			=	k
     print(lowercase__	)





def      _a		(lowercase__ :      int       ,      lowercase__ :      Tuple	) -> Any:






     """simple docstring"""
     __snake_case			,					__snake_case			,					__snake_case    			=	{s: 0}, set(), {s: 0}
     while True:
          if len(lowercase__	) == len(lowercase__	) - 1:
               break
          __snake_case    			=	1_0_0_0_0_0
          for i in dist:
               if i not in known and dist[i] < mini:
                    __snake_case    			=	dist[i]
                    __snake_case    			=	i
          known.add(lowercase__	)
          for v in g[u]:
               if v[0] not in known and v[1] < dist.get(v[0]       ,      1_0_0_0_0_0	):
                    __snake_case    			=	v[1]
                    __snake_case    			=	u
     return dist





def      _a		() -> List[Any]:






     """simple docstring"""
     __snake_case			,					__snake_case    			=	map(lowercase__       ,      input().split(' '	)	)
     __snake_case    			=	[]
     for _ in range(lowercase__	):
          edges.append(map(lowercase__       ,      input().split(' '	)	)	)
     return edges, n





def      _a		(lowercase__ :      str	) -> List[Any]:






     """simple docstring"""
     # Sort edges on the basis of distance
     ((__snake_case)			,					(__snake_case))    			=	e_and_n
     e.sort(reverse=lowercase__       ,      key=lambda lowercase__	: x[2]	)
     __snake_case    			=	[{i} for i in range(1       ,      n + 1	)]
     while True:
          if len(lowercase__	) == 1:
               break
          print(lowercase__	)
          __snake_case    			=	e.pop()
          for i in range(len(lowercase__	)	):
               if x[0] in s[i]:
                    break
          for j in range(len(lowercase__	)	):
               if x[1] in s[j]:
                    if i == j:
                         break
                    s[j].update(s[i]	)
                    s.pop(lowercase__	)
                    break





def      _a		(lowercase__ :      Any	) -> Any:






     """simple docstring"""
     __snake_case    			=	[]
     for node in graph:
          if not graph[node]:
               isolated.append(lowercase__	)
     return isolated








'''simple docstring'''




import warnings
from collections.abc import Callable
from typing import Any

import numpy
from matplotlib import pyplot

_a      :      Optional[int]       				=      0.25 + 0.0J
_a      :      Dict       				=      -0.4 + 0.6J
_a      :      List[str]       				=      -0.1 + 0.651J
_a      :      Optional[int]       				=      -2.0
_a      :      List[str]       				=      56
_a      :      Tuple       				=      2.0
_a      :      List[str]       				=      666





def      _a		(lowercase__ :      complex       ,      lowercase__ :      numpy.ndarray	) -> numpy.ndarray:






     """simple docstring"""
     return numpy.exp(lowercase__	) + c_parameter





def      _a		(lowercase__ :      complex       ,      lowercase__ :      numpy.ndarray	) -> numpy.ndarray:






     """simple docstring"""
     return z_values * z_values + c_parameter





def      _a		(lowercase__ :      float       ,      lowercase__ :      int	) -> numpy.ndarray:






     """simple docstring"""
     __snake_case    			=	numpy.linspace(-window_size       ,      lowercase__       ,      lowercase__	)
     __snake_case    			=	x.reshape((nb_pixels, 1)	)
     __snake_case    			=	numpy.linspace(-window_size       ,      lowercase__       ,      lowercase__	)
     __snake_case    			=	y.reshape((1, nb_pixels)	)
     return x + 1.0J * y





def      _a		(lowercase__ :      Callable[[Any, numpy.ndarray], numpy.ndarray]       ,      lowercase__ :      Any       ,      lowercase__ :      int       ,      lowercase__ :      numpy.ndarray       ,      lowercase__ :      float | None = None       ,      ) -> numpy.ndarray:






     """simple docstring"""
     __snake_case    			=	z_a.astype('complex64'	)
     for _ in range(lowercase__	):
          __snake_case    			=	eval_function(lowercase__       ,      lowercase__	)
          if infinity is not None:
               numpy.nan_to_num(lowercase__       ,      copy=lowercase__       ,      nan=lowercase__	)
               __snake_case    			=	infinity
     return z_n





def      _a		(lowercase__ :      str       ,      lowercase__ :      Any       ,      lowercase__ :      float       ,      lowercase__ :      numpy.ndarray       ,      ) -> None:






     """simple docstring"""
     __snake_case    			=	(abs(lowercase__	)).transpose()
     __snake_case    			=	abs_z_final[::-1, :]
     pyplot.matshow(abs_z_final < escape_radius	)
     pyplot.title(f'Julia set of ${function_label}$, $c={function_params}$'	)
     pyplot.show()





def      _a		() -> None:






     """simple docstring"""
     warnings.filterwarnings(
         'ignore'       ,      category=lowercase__       ,      message='overflow encountered in multiply'	)
     warnings.filterwarnings(
         'ignore'       ,      category=lowercase__       ,      message='invalid value encountered in multiply'       ,      )
     warnings.filterwarnings(
         'ignore'       ,      category=lowercase__       ,      message='overflow encountered in absolute'	)
     warnings.filterwarnings(
         'ignore'       ,      category=lowercase__       ,      message='overflow encountered in exp'	)


if __name__ == "__main__":
       _a      :      List[Any]       				=      prepare_grid(window_size, nb_pixels)

       ignore_overflow_warnings()  # See file header for explanations

       _a      :      Optional[Any]       				=      24
       _a      :      Optional[int]       				=      2 * abs(c_cauliflower) + 1
       _a      :      List[str]       				=      iterate_function(
           eval_quadratic_polynomial,
           c_cauliflower,
           nb_iterations,
           z_a,
           infinity=1.1 * escape_radius,
       )
       show_results("z^2+c", c_cauliflower, escape_radius, z_final)

       _a      :      str       				=      64
       _a      :      Tuple       				=      2 * abs(c_polynomial_a) + 1
       _a      :      List[Any]       				=      iterate_function(
           eval_quadratic_polynomial,
           c_polynomial_a,
           nb_iterations,
           z_a,
           infinity=1.1 * escape_radius,
       )
       show_results("z^2+c", c_polynomial_a, escape_radius, z_final)

       _a      :      List[Any]       				=      161
       _a      :      Tuple       				=      2 * abs(c_polynomial_a) + 1
       _a      :      int       				=      iterate_function(
           eval_quadratic_polynomial,
           c_polynomial_a,
           nb_iterations,
           z_a,
           infinity=1.1 * escape_radius,
       )
       show_results("z^2+c", c_polynomial_a, escape_radius, z_final)

       _a      :      str       				=      12
       _a      :      Optional[Any]       				=      10_000.0
       _a      :      Dict       				=      iterate_function(
           eval_exponential,
           c_exponential,
           nb_iterations,
           z_a + 2,
           infinity=1.0e1_0,
       )
       show_results("e^z+c", c_exponential, escape_radius, z_final)




