




'''simple docstring'''



from collections import deque
def 				SCREAMING_SNAKE_CASE_				(							__A       :				Optional[int]						)				->				List[Any]:
   return input(__A						).strip().split(" "						)
def 				SCREAMING_SNAKE_CASE_				(							__A       :				int ,  __A       :				int						)				->				dict[int, list[int]]:
   _SCREAMING_SNAKE_CASE =   {}
   for i in range(__A						):
      _SCREAMING_SNAKE_CASE =   []

   for e in range(__A						):
      _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   (int(__A						) for i in _input(f"""Edge {e + 1}: <node1> <node2> """						))
      graph[x].append(__A						)
   return graph
def 				SCREAMING_SNAKE_CASE_				(							__A       :				int ,  __A       :				int						)				->				dict[int, list[int]]:
   _SCREAMING_SNAKE_CASE =   {}
   for i in range(__A						):
      _SCREAMING_SNAKE_CASE =   []

   for e in range(__A						):
      _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   (int(__A						) for i in _input(f"""Edge {e + 1}: <node1> <node2> """						))
      graph[x].append(__A						)
      graph[y].append(__A						)
   return graph
def 				SCREAMING_SNAKE_CASE_				(							__A       :				int ,  __A       :				int						)				->				dict[int, list[tuple[int, int]]]:
   _SCREAMING_SNAKE_CASE =   {}
   for i in range(__A						):
      _SCREAMING_SNAKE_CASE =   []

   for e in range(__A						):
      _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   (int(__A						) 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__":
 lowerCamelCase_ ,       lowerCamelCase_	 =		(int(i) for i in _input('Number of nodes and edges: '))

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

 lowerCamelCase_	 =		{
     1: initialize_unweighted_directed_graph,
     2: initialize_unweighted_undirected_graph,
     3: initialize_weighted_undirected_graph,
 }[graph_choice](n, m)
def 				SCREAMING_SNAKE_CASE_				(							__A       :				int ,  __A       :				Any						)				->				List[Any]:
   _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   {s}, [s]
   print(__A						)
   while _s:
      _SCREAMING_SNAKE_CASE =   0
      for i in g[_s[-1]]:
         if i not in vis:
            _s.append(__A						)
            vis.add(__A						)
            _SCREAMING_SNAKE_CASE =   1
            print(__A						)
            break
      if not flag:
         _s.pop()
def 				SCREAMING_SNAKE_CASE_				(							__A       :				Optional[int] ,  __A       :				List[Any]						)				->				str:
   _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   {s}, deque([s]						)
   print(__A						)
   while q:
      _SCREAMING_SNAKE_CASE =   q.popleft()
      for v in g[u]:
         if v not in vis:
            vis.add(__A						)
            q.append(__A						)
            print(__A						)
def 				SCREAMING_SNAKE_CASE_				(							__A       :				Optional[Any] ,  __A       :				Dict						)				->				List[Any]:
   _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   {s: 0}, set(), {s: 0}
   while True:
      if len(__A						) == len(__A						) - 1:
         break
      _SCREAMING_SNAKE_CASE =   10_00_00
      for i in dist:
         if i not in known and dist[i] < mini:
            _SCREAMING_SNAKE_CASE =   dist[i]
            _SCREAMING_SNAKE_CASE =   i
      known.add(__A						)
      for v in g[u]:
         if v[0] not in known and dist[u] + v[1] < dist.get(v[0] ,  10_00_00						):
            _SCREAMING_SNAKE_CASE =   dist[u] + v[1]
            _SCREAMING_SNAKE_CASE =   u
   for i in dist:
      if i != s:
         print(dist[i]						)
def 				SCREAMING_SNAKE_CASE_				(							__A       :				Tuple ,  __A       :				List[Any]=None ,  __A       :				Dict=None						)				->				int:
   if q is None:
      _SCREAMING_SNAKE_CASE =   [1]
   if ind is None:
      _SCREAMING_SNAKE_CASE =   [0] * (len(__A						) + 1)  # SInce oth Index is ignored
      for u in g:
         for v in g[u]:
            ind[v] += 1
      _SCREAMING_SNAKE_CASE =   deque()
      for i in g:
         if ind[i] == 0:
            q.append(__A						)
   if len(__A						) == 0:
      return
   _SCREAMING_SNAKE_CASE =   q.popleft()
   print(__A						)
   for w in g[v]:
      ind[w] -= 1
      if ind[w] == 0:
         q.append(__A						)
   topo(__A ,  __A ,  __A						)
def 				SCREAMING_SNAKE_CASE_				(							)				->				int:
   _SCREAMING_SNAKE_CASE =   input().strip()
   _SCREAMING_SNAKE_CASE =   []
   for _ in range(__A						):
      a.append(map(__A ,  input().strip().split()						)						)
   return a, n
def 				SCREAMING_SNAKE_CASE_				(							__A       :				str						)				->				str:
   ((_SCREAMING_SNAKE_CASE), (_SCREAMING_SNAKE_CASE)) =   a_and_n
   _SCREAMING_SNAKE_CASE =   list(__A						)
   _SCREAMING_SNAKE_CASE =   [[0] * n for i in range(__A						)]
   for k in range(__A						):
      for i in range(__A						):
         for j in range(__A						):
            if dist[i][j] > dist[i][k] + dist[k][j]:
               _SCREAMING_SNAKE_CASE =   dist[i][k] + dist[k][j]
               _SCREAMING_SNAKE_CASE =   k
   print(__A						)
def 				SCREAMING_SNAKE_CASE_				(							__A       :				Any ,  __A       :				Union[str, Any]						)				->				Optional[Any]:
   _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   {s: 0}, set(), {s: 0}
   while True:
      if len(__A						) == len(__A						) - 1:
         break
      _SCREAMING_SNAKE_CASE =   10_00_00
      for i in dist:
         if i not in known and dist[i] < mini:
            _SCREAMING_SNAKE_CASE =   dist[i]
            _SCREAMING_SNAKE_CASE =   i
      known.add(__A						)
      for v in g[u]:
         if v[0] not in known and v[1] < dist.get(v[0] ,  10_00_00						):
            _SCREAMING_SNAKE_CASE =   v[1]
            _SCREAMING_SNAKE_CASE =   u
   return dist
def 				SCREAMING_SNAKE_CASE_				(							)				->				Dict:
   _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   map(__A ,  input().split(" "						)						)
   _SCREAMING_SNAKE_CASE =   []
   for _ in range(__A						):
      edges.append(map(__A ,  input().split(" "						)						)						)
   return edges, n
def 				SCREAMING_SNAKE_CASE_				(							__A       :				Optional[int]						)				->				str:
   # Sort edges on the basis of distance
   ((_SCREAMING_SNAKE_CASE), (_SCREAMING_SNAKE_CASE)) =   e_and_n
   e.sort(reverse=__A ,  key=lambda __A						: x[2]						)
   _SCREAMING_SNAKE_CASE =   [{i} for i in range(1 ,  n + 1						)]
   while True:
      if len(__A						) == 1:
         break
      print(__A						)
      _SCREAMING_SNAKE_CASE =   e.pop()
      for i in range(len(__A						)						):
         if x[0] in s[i]:
            break
      for j in range(len(__A						)						):
         if x[1] in s[j]:
            if i == j:
               break
            s[j].update(s[i]						)
            s.pop(__A						)
            break






def 				SCREAMING_SNAKE_CASE_				(							__A       :				str						)				->				Optional[Any]:
   _SCREAMING_SNAKE_CASE =   []
   for node in graph:
      if not graph[node]:
         isolated.append(__A						)
   return isolated







'''simple docstring'''



lowerCamelCase_	 =		(1, 1_53, 3_70, 3_71, 16_34, 24_67_80_51, 1_15_13_22_19_01_87_63_99_25_65_09_55_97_97_39_71_52_24_01)
lowerCamelCase_	 =		(-1_53, -1, 0, 1.2, 2_00, "A", [], {}, None)
def 				SCREAMING_SNAKE_CASE_				(							__A       :				int						)				->				bool:
   if not isinstance(__A ,  __A						) or n < 1:
      return False

   # Initialization of sum and number of digits.
   _SCREAMING_SNAKE_CASE =   0
   _SCREAMING_SNAKE_CASE =   0
   _SCREAMING_SNAKE_CASE =   n
   # Calculation of digits of the number
   while temp > 0:
      number_of_digits += 1
      temp //= 10
   # Dividing number into separate digits and find Armstrong number
   _SCREAMING_SNAKE_CASE =   n
   while temp > 0:
      _SCREAMING_SNAKE_CASE =   temp % 10
      total += rem**number_of_digits
      temp //= 10
   return n == total
def 				SCREAMING_SNAKE_CASE_				(							__A       :				int						)				->				bool:
   if not isinstance(__A ,  __A						) or n < 1:
      return False

   # Init a "histogram" of the digits
   _SCREAMING_SNAKE_CASE =   [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
   _SCREAMING_SNAKE_CASE =   0
   _SCREAMING_SNAKE_CASE =   0
   _SCREAMING_SNAKE_CASE =   n
   while temp > 0:
      _SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE =   divmod(__A ,  10						)
      digit_histogram[rem] += 1
      digit_total += 1

   for cnt, i in zip(__A ,  range(len(__A						)						)						):
      total += cnt * i**digit_total

   return n == total
def 				SCREAMING_SNAKE_CASE_				(							__A       :				int						)				->				bool:
   if not isinstance(__A ,  __A						) or n < 1:
      return False
   _SCREAMING_SNAKE_CASE =   len(str(__A						)						)  # the power that all digits will be raised to
   # check if sum of each digit multiplied expo times is equal to number
   return n == sum(int(__A						) ** expo for i in str(__A						)						)
def 				SCREAMING_SNAKE_CASE_				(							)				->				Optional[Any]:
   _SCREAMING_SNAKE_CASE =   int(input("Enter an integer to see if it is an Armstrong number: "						).strip()						)
   print(f"""{num} is {"" if armstrong_number(__A						) else "not "}an Armstrong number."""						)
   print(f"""{num} is {"" if narcissistic_number(__A						) else "not "}an Armstrong number."""						)
   print(f"""{num} is {"" if pluperfect_number(__A						) else "not "}an Armstrong number."""						)


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 main()

