


"""simple docstring"""


class  lowercase:  # Public class to implement a graph







 '''simple docstring'''





 def __init__(    self:		str,				a_:		Tuple,				a_:		Dict,				a_:		Dict		):




   '''simple docstring'''



   _snake_case							:		Optional[int]								=  row
   _snake_case							:		Any								=  col
   _snake_case							:		Union[str, Any]								=  graph


 def 			UpperCamelCase_       (    self:		Any,				a_:		Any,				a_:		Union[str, Any],				a_:		Tuple		):




   '''simple docstring'''



   return (
       0 <= i < self.ROW
       and 0 <= j < self.COL
       and not visited[i][j]
       and self.graph[i][j]
   )


 def 			UpperCamelCase_       (    self:		Tuple,				a_:		List[str],				a_:		Dict,				a_:		Optional[int]		):




   '''simple docstring'''



   _snake_case							:		Union[str, Any]								=  [-1, -1, -1, 0, 0, 1, 1, 1]  # Coordinate order
   _snake_case							:		Union[str, Any]								=  [-1, 0, 1, -1, 1, -1, 0, 1]
   _snake_case							:		Dict								=  True  # Make those cells visited
   for k in range(8		):
     if self.is_safe(i + row_nbr[k],				j + col_nbr[k],				a_		):
       self.diffs(i + row_nbr[k],				j + col_nbr[k],				a_		)


 def 			UpperCamelCase_       (    self:		str		):  # And finally, count all islands.




   '''simple docstring'''



   _snake_case							:		List[str]								=  [[False for j in range(self.COL		)] for i in range(self.ROW		)]
   _snake_case							:		Dict								=  0
   for i in range(self.ROW		):
     for j in range(self.COL		):
       if visited[i][j] is False and self.graph[i][j] == 1:
         self.diffs(a_,				a_,				a_		)
         count += 1
   return count








"""simple docstring"""


from typing import Any






class  lowercase:







 '''simple docstring'''





 def __init__(    self:		Dict,				a_:		Any		):




   '''simple docstring'''



   _snake_case							:		Dict								=  data
   _snake_case							:		Optional[Any]								=  None







class  lowercase:







 '''simple docstring'''





 def __init__(    self:		str		):




   '''simple docstring'''



   _snake_case							:		Any								=  None


 def 			UpperCamelCase_       (    self:		Any		):




   '''simple docstring'''



   _snake_case							:		List[Any]								=  self.head
   while temp is not None:
     print(temp.data,				end=""" """		)
     _snake_case							:		int								=  temp.next
   print()


 def 			UpperCamelCase_       (    self:		Union[str, Any],				a_:		Any		):




   '''simple docstring'''



   _snake_case							:		Optional[Any]								=  Node(a_		)
   _snake_case							:		Union[str, Any]								=  self.head
   _snake_case							:		List[Any]								=  new_node


 def 			UpperCamelCase_       (    self:		Tuple,				a_:		List[str],				a_:		Union[str, Any]		):




   '''simple docstring'''



   if node_data_a == node_data_a:
     return
   else:
     _snake_case							:		int								=  self.head
     while node_a is not None and node_a.data != node_data_a:
       _snake_case							:		List[Any]								=  node_a.next

     _snake_case							:		List[Any]								=  self.head
     while node_a is not None and node_a.data != node_data_a:
       _snake_case							:		List[Any]								=  node_a.next

     if node_a is None or node_a is None:
       return

     _snake_case		, _snake_case							:		int								=  node_a.data, node_a.data


if __name__ == "__main__":
     A_      =    LinkedList()
     for i in range(5, 0, -1):
          ll.push(i)

     ll.print_list()

     ll.swap_nodes(1, 4)
     print('''After swapping''')
     ll.print_list()


