





"""simple docstring"""




class  __UpperCamelCase       :  # Public class to implement a graph






							def __init__(     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				None:
								a   :	Optional[Any]			=       row
								a   :	Tuple			=       col
								a   :	str			=       graph






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				bool:
								return (
								    0 <= i < self.ROW
								    and 0 <= j < self.COL
								    and not visited[i][j]
								    and self.graph[i][j]
								)






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				None:
								# Checking all 8 elements surrounding nth element
								a   :	Optional[int]			=       [-1, -1, -1, 0, 0, 1, 1, 1]  # Coordinate order
								a   :	List[str]			=       [-1, 0, 1, -1, 1, -1, 0, 1]
								a   :	Dict			=       True  # Make those cells visited
								for k in range(8   ):
									if self.is_safe(i + row_nbr[k]   ,      j + col_nbr[k]   ,      lowerCAmelCase__   ):
										self.diffs(i + row_nbr[k]   ,      j + col_nbr[k]   ,      lowerCAmelCase__   )






							def 					__a     (     self   )			->				int:  # And finally, count all islands.
								a   :	List[str]			=       [[False for j in range(self.COL   )] for i in range(self.ROW   )]
								a   :	int			=       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(lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )
											count += 1
								return count









"""simple docstring"""




import baseaa






def    _SCREAMING_SNAKE_CASE	(			_lowercase		:					str      )				->bytes:






	'''simple docstring'''






	return baseaa.aaaencode(string.encode("utf-8"      )      )






def    _SCREAMING_SNAKE_CASE	(			_lowercase		:					bytes      )				->str:






	'''simple docstring'''






	return baseaa.aaadecode(_lowercase      ).decode("utf-8"      )


if __name__ == "__main__":
		import doctest

		doctest.testmod()


