





class 			lowercase				:  # Public class to implement a graph



      """simple docstring"""

      def __init__(    self			:		Any ,				lowerCamelCase_			:		int ,				lowerCamelCase_			:		int ,				lowerCamelCase_			:		list[list[bool]]					):





          '''simple docstring'''







          _snake_case :			List[str]  						=   row
          _snake_case :			Tuple  						=   col
          _snake_case :			List[Any]  						=   graph







      def 		__UpperCAmelCase       (    self			:		Dict ,				lowerCamelCase_			:		int ,				lowerCamelCase_			:		int ,				lowerCamelCase_			:		list[list[bool]]					):





          '''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			:		List[Any] ,				lowerCamelCase_			:		int ,				lowerCamelCase_			:		int ,				lowerCamelCase_			:		list[list[bool]]					):





          '''simple docstring'''







          _snake_case :			int  						=   [-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 :			str  						=   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 		__UpperCAmelCase       (    self			:		str					):  # And finally, count all islands.





          '''simple docstring'''







          _snake_case :			List[Any]  						=   [[False for j in range(self.COL					)] for i in range(self.ROW					)]
          _snake_case :			List[str]  						=   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













from math import factorial

def       A__(		__lowerCAmelCase	,			__lowerCAmelCase	,			__lowerCAmelCase ):
				if successes > trials:
								raise ValueError('successes must be lower or equal to trials' )
				if trials < 0 or successes < 0:
								raise ValueError('the function is defined for non-negative integers' )
				if not isinstance(__lowerCAmelCase	,			__lowerCAmelCase ) or not isinstance(__lowerCAmelCase	,			__lowerCAmelCase ):
								raise ValueError('the function is defined for non-negative integers' )
				if not 0 < prob < 1:
								raise ValueError('prob has to be in range of 1 - 0' )
				_snake_case :			Optional[int]  						=   (prob**successes) * ((1 - prob) ** (trials - successes))
				# Calculate the binomial coefficient: n! / k!(n-k)!
				_snake_case :			List[Any]  						=   float(factorial(__lowerCAmelCase ) )
				coefficient /= factorial(__lowerCAmelCase ) * factorial(trials - successes )
				return probability * coefficient


if __name__ == "__main__":
		from doctest import testmod

		testmod()
		print('''Probability of 2 successes out of 4 trails''')
		print('''with probability of 0.75 is:''', end=''' ''')
		print(binomial_distribution(2, 4, 0.75))






